-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Make knn search as a query #97940
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
Comments
Pinging @elastic/es-search (Team:Search) |
I wonder how we could make knn a query that still runs in the dfs phase, while being able to combine it with other queries. We'd need to be able to extract knn queries from the query tree, run them separately and rewrite them into something else for the query phase, similar to what we already do after we run the dfs phase? I also wonder if we added a knn query that only runs in the query phase, how would that integrate with aggregations? |
@javanna Very good questions. I need to think more about your first question.
For |
IMO, this is a feature, not a limitation. This increases recall and if folks only want vectors that fit within a similarity, they have the There are a couple of things that concern me on the query layer we need to be careful about:
|
Another thing to consider is that if this query supports searching over non-indexed vectors. I think it should. We should have a parameter called Something like:
This would also work for things indexed in HNSW. Instead of searching the graph, we iterate all vectors using the provided similarity. In this case, I think we could allow |
This issue blocks #97541 as we need to ensure our design for the knn Query is acceptable as is before we attempt to add new things to it that the top level knn doesn't support. |
@mayya-sharipova thank you so much for your contributions to this project! Just checking in to see if there's an update or if you might have an idea of when you'll have a chance to look at this further. Thanks again! |
@saiparsa I am wondering what is your need for knn as query? We already have top level knn search, is there something you can't accomplish with it? |
@mayya-sharipova Thanks for the reply! We're attempting to leverage KNN for querying embeddings in child docs while concurrently searching metadata in parent docs. However, current Elasticsearch limits prevent KNN from being nested within has_child queries, limiting our desired query approach. |
@mayya-sharipova I would love to look |
Closed by #98916 |
Thank you so much @mayya-sharipova for working on this. You're the best! This is a really important feature people have been awaiting. If it's not too much to ask, could you please help us understand if this enhancement would be part of the 8.11 series of releases or will it be available in a new series such as 8.12. |
@rishubhgupta Thank you for your kind words. This will be available from 8.12 |
When is this version coming for 8.12 |
Uh oh!
There was an error while loading. Please reload this page.
Description
Currently knn is a top section of a search request. knn search runs in the DFS phase, which allows to collect global top k results regardless of a number of shards. This is very useful for aggregations, as only global top K results will be included in aggregations' results.
A limitation of having knn as a top section is that knn search by itself can not be combined or nested within other queries.
There are two ways to approach this:
knn_shard
query that works on a shard level in the Query phase similar to all other queries.knn
as a query, but keep the internal implementation the same (i.e. internally knn search will still run during DFS phase and collect top global k).The text was updated successfully, but these errors were encountered: