Skip to content

Multiple levels of field collapse #24855

@eskibars

Description

@eskibars

Describe the feature:
Currently, we support 1 level of field collapse + inner hits (https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-request-collapse.html#_expand_collapse_results). However, some users need to collapse multiple levels (while still providing features provided by field collapse, e.g. pagination), e.g. to simply provide the top item for 2 tiers of collapsing. For those users, they have a few options:

  1. Ignore the pagination requirement and do terms+terms+top_hits (which will be fine for some users)
  2. In a single query, ask for a very large inner_hits size and then reduce the set client-side
  3. Perform multiple queries: 1 for the first collapse level and then iterate through these for secondary queries

When 1 is not an option for business purposes, this leaves you with options 2 and 3. 2 is a fairly abusive/expensive way to solve it when you're looking for just the top result under each of the top-level collapse. 3 adds a lot of client code as well as round trips (which increase overall query latency).

Unfortunately, opening up multiple levels also opens the query up for abuse in different ways (asking for high depth)

I wanted to open up for discussion the possibility of having multiple levels of field collapse, even if there were additional restrictions (e.g. only 2 levels, only can return a much smaller result set from the second level, etc)

Metadata

Metadata

Labels

:Search/SearchSearch-related issues that do not fall into other categories>enhancement

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions