-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Integrate ANN into _search endpoint #88694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR adds a new `knn` section to the search request. As explained in #87625, the search returns a global top k documents across all shards: * In the DFS phase, collect the top k vector matches per shard, combine them and keep the global top k. * Then move to the query phase. Convert the top k vector matches into a new `KnnScoreDocQueryBuilder` that matches only those top documents. For the final query, take a boolean disjunction between this `KnnScoreDocQueryBuilder` query and the search request `query`. Commits: * Rename KnnSearchRequestBuilder -> KnnSearchRequestParser to avoid confusion with new KnnSearchBuilder * Add `KnnScoreDocQueryBuilder` * Implement kNN search using DFS phase Addresses #87625.
This PR introduces a 'filter' subsection where filters can be provided to the kNN search. Like all other queries, the filters are rewritten on the coordinating nodes as well as data nodes.
When kNN search is enabled, it automatically uses the `dfs_query_then_fetch` search type. The user can no longer control the search type that's used. This commit throws an error if `search_type` is explicitly set when `knn` search is used.
This change adds docs for the new search `knn` option: * Add `knn` option to `_search` API docs. * Update the kNN search guide to use the `_search` endpoint instead of `_knn_search` endpoint. Move relevant information from the `_knn_search` API docs to this guide, like the filtering example. * Add an example to the kNN search guide of configuring `index_options` (just seemed nice to have, not core to this change). The PR doesn't deprecate the `_knn_search` endpoint yet.
Each commit was reviewed earlier:
There are some follow-ups tracked in #87625 that we'll tackle after this initial merge. |
Pinging @elastic/es-search (Team:Search) |
Hi @jtibshirani, I've created a changelog YAML for you. Note that since this PR is labelled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtibshirani Thanks Julie, considering that everything was reviewed before, I only quickly browsed this PR and everything LGTM.
Add a note that approximate knn search doesn't support the parameter ccs_minimize_roundtrips in CCS search. Relates to elastic#88694
Add a note that approximate knn search doesn't support the parameter ccs_minimize_roundtrips in CCS search. Relates to #88694
This PR adds a new
knn
option to the_search
API to support ANN search.It's powered by the same Lucene ANN capabilities as the old
_knn_search
endpoint. The
knn
option can be combined with other search features likequeries and aggregations.
Addresses #87625