Skip to content

[WIP] ESQL - KNN function uses LIMIT for K, transforms to exact search when not pushed down #132944

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

carlosdelest
Copy link
Member

@carlosdelest carlosdelest commented Aug 14, 2025

Changes how KNN works for ESQL:

  • k is no longer specified as a parameter
  • LIMIT is used to provide the k parameter
  • When knn can't be pushed down to Lucene, it is transformed into an exact search
  • Instead of num_candidates, users can provide min_candidates. That is the minimum number of candidates to use, as in case the query is transformed into an exact search we can't really guarantee that we will be evaluating num_candidates at the most
  • In case min_candidates is specified, then it is used as k

@carlosdelest carlosdelest added :Analytics/ES|QL AKA ESQL :SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch :Search Relevance/ES|QL Search functionality in ES|QL labels Aug 14, 2025
…earch-non-pushed' into non-issue/esql-knn-exact-search-non-pushed

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/KnnQuery.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL :Search Relevance/ES|QL Search functionality in ES|QL :SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants