File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ The ``Search`` object represents the entire search request:
18
18
19
19
* pagination
20
20
21
+ * highlighting
22
+
23
+ * suggestions
24
+
25
+ * collapsing
26
+
21
27
* additional parameters
22
28
23
29
* associated client
@@ -433,7 +439,26 @@ keyword arguments will be added to the suggest's json as-is which means that it
433
439
should be one of ``term ``, ``phrase `` or ``completion `` to indicate which type
434
440
of suggester should be used.
435
441
442
+ Collapsing
443
+ ~~~~~~~~~~
444
+
445
+ To collapse search results use the ``collapse `` method on your ``Search `` object:
446
+
447
+ .. code :: python
448
+
449
+ s = Search().query(" match" , message = " GET /search" )
450
+ # collapse results by user_id
451
+ s = s.collapse(" user_id" )
452
+
453
+ The top hits will only include one result per ``user_id ``. You can also expand
454
+ each collapsed top hit with the ``inner_hits `` parameter,
455
+ ``max_concurrent_group_searches `` being the number of concurrent requests
456
+ allowed to retrieve the inner hits per group:
457
+
458
+ .. code :: python
436
459
460
+ inner_hits = {" name" : " recent_search" , " size" : 5 , " sort" : [{" @timestamp" : " desc" }]}
461
+ s = s.collapse(" user_id" , inner_hits = inner_hits, max_concurrent_group_searches = 4 )
437
462
438
463
More Like This Query
439
464
~~~~~~~~~~~~~~~~~~~~
You can’t perform that action at this time.
0 commit comments