Skip to content

Conversation

@tteofili
Copy link
Contributor

@tteofili tteofili commented Apr 23, 2025

This exposes an option to add the patience-based early termination defined in apache/lucene#14094 to KNN queries in ES.
This leverages PatienceKnnVectorQuery which wraps ES KNN queries when mapping is one of hnsw, int8_hnsw, int4_hnsw, bbq_hnsw and early_termination is set to true (within index_options).

e.g.:

{
  "mappings": {
    "properties": {
      "my_vector" : {
        "type": "dense_vector",
        "dims" : 10,
        "index" : true,
        "index_options" : {
          "type" : "bbq_hnsw"
          "early_termination" : true
        }
      }
    }
  }
}

Currently this has the limitation that we can't profile that query because we can't extend the PatienceKnnQuery same as https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/search/vectors/ESKnnByteVectorQuery.java#L28-L38 because of visibility issues. However it's fixed in 10.3 branch via apache/lucene#14838 and we'll incorporate that as soon as 10.3 is released and included in ES main branch.

@tteofili
Copy link
Contributor Author

tteofili commented May 9, 2025

dense_vector
Screenshot 2025-05-09 at 16 16 13
Screenshot 2025-05-09 at 16 17 08

@tteofili
Copy link
Contributor Author

so_vector
Screenshot 2025-05-29 at 15 40 18
Screenshot 2025-05-29 at 15 40 35
Screenshot 2025-05-29 at 15 37 07
Screenshot 2025-05-29 at 15 37 27
Screenshot 2025-05-29 at 15 37 56

@github-actions
Copy link
Contributor

github-actions bot commented Jun 19, 2025

🔍 Preview links for changed docs:

🔔 The preview site may take up to 3 minutes to finish building. These links will become live once it completes.

@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jun 27, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Hi @tteofili, I've created a changelog YAML for you.

@tteofili tteofili requested a review from a team as a code owner June 30, 2025 12:21
Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whew, way cleaner! Still some room for simplifying. But the index setting looks much nicer to me :)

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So clean! I like it, and the performance numbers are ⚡

@M12b4
Copy link

M12b4 commented Jul 1, 2025 via email

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@tteofili tteofili merged commit 9edfa66 into elastic:main Jul 1, 2025
30 of 32 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

The backport operation could not be completed due to the following error:

There are no branches to backport to. Aborting.

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 127223

@tteofili tteofili removed the auto-backport Automatically create backport pull requests when merged label Jul 1, 2025
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 3, 2025
@shainaraskas shainaraskas added the docs-missing-applies-tags PRs that are missing docs applies_to tags for an upcoming release. label Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport pending docs-missing-applies-tags PRs that are missing docs applies_to tags for an upcoming release. >feature :Search Relevance/Vectors Vector search 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.

5 participants