Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion _search-plugins/searching-data/collapse-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,33 @@ The `collapse` parameter affects only the top search results and does not change

---

## Collapse with search_after

You can paginate collapsed search results using the `search_after` parameter. The collapse field and sort field must be the same, and only one sort field can be specified.

The following example shows how to use collapse with `search_after`:

```json
GET /bakery-items/_search
{
"query": {
"match": {
"category": "cakes"
}
},
"collapse": {
"field": "item"
},
"sort": [
{
"item": "asc"
}
],
"search_after": ["Chocolate Cake"]
}

```

## Expanding collapsed results

You can expand each collapsed top hit with the `inner_hits` property.
Expand Down Expand Up @@ -229,4 +256,4 @@ GET /bakery-items/_search

This query searches for documents in the `cakes` category and groups the search results by the `item_name` field. For each `item_name`, it retrieves the top three lowest-priced items and the top three most recent items, sorted by `baked_date` in descending order.

You can expand the groups by sending an additional query for each inner hit request corresponding to each collapsed hit in the response. This can significantly slow down the process if there are too many groups or inner hit requests. The `max_concurrent_group_searches` request parameter can be used to control the maximum number of concurrent searches allowed in this phase. The default is based on the number of data nodes and the default search thread pool size.
You can expand the groups by sending an additional query for each inner hit request corresponding to each collapsed hit in the response. This can significantly slow down the process if there are too many groups or inner hit requests. The `max_concurrent_group_searches` request parameter can be used to control the maximum number of concurrent searches allowed in this phase. The default is based on the number of data nodes and the default search thread pool size.