Inner hits in search queries

Description

Elasticsearch provides a way to return “inner hits” in search queries:

Essentially, that means, for any nested predicate, we’ll assign a name to that predicate, and the SearchResult will contain a separate result set with that name, whose hits are objects matched by the corresponding nested predicate.

See the Elasticsearch documentation for more details.

There are two main challenges:

  1. How to represent the inner hits? Most likely, we’ll need either to load entities corresponding to the nested objects, or a way for developers to define a projection on the nested objects.

  2. How to implement this efficiently with the Lucene backend? Let’s not look at the Elasticsearch 7.11+ implementation, the license doesn’t allow us to take inspiration from their code. We can look at Elasticsearch 7.10 and below as well as OpenSearch, though.

Activity

Details

Assignee

Reporter

Components

Priority

Created July 11, 2022 at 7:16 AM
Updated September 25, 2023 at 2:48 PM