Skip to content

Improve HNSW filtered search speed through new heuristic #126876

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

Merged

Conversation

benwtrent
Copy link
Member

Apache Lucene 10.2 exposes a new search strategy for executing filtered searches over HNSW graphs.

This PR switches to utilizing that strategy by default as it generally provides a much better recall/latency pareto frontier than our regular hnsw fanout search.

Additionally, a new tech-preview setting is provided to potentially revert to the old fanout behavior if issues arise.

@benwtrent benwtrent requested a review from a team as a code owner April 15, 2025 19:40
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Apr 15, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

@benwtrent
Copy link
Member Author

I have been thinking about this more, I am thinking that for EXISTING indices, we do not change the default behavior (e.g. it should be fanout), but for NEW indices, we should. This complicates things, but the recall/latency behavior seems to justify this I think.

The other option is we default to fanout always requiring an "opt-in" to use acorn. I would rather attempt to default to acorn on new indices. But, its tricky.

What do you think @jimczi @mayya-sharipova ?

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tteofili tteofili left a comment

Choose a reason for hiding this comment

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

LGTM

@benwtrent benwtrent merged commit 8bb7dc4 into elastic:main May 6, 2025
17 checks passed
@benwtrent benwtrent deleted the feature/better-vector-filtered-search branch May 6, 2025 17:43
parkertimmins pushed a commit to parkertimmins/elasticsearch that referenced this pull request May 7, 2025
)

Apache Lucene 10.2 exposes a new search strategy for executing filtered searches over HNSW graphs.

This PR switches to utilizing that strategy by default as it generally provides a much better recall/latency pareto frontier than our regular hnsw fanout search.

Additionally, a new tech-preview setting is provided to potentially revert to the old fanout behavior if issues arise.
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request May 9, 2025
)

Apache Lucene 10.2 exposes a new search strategy for executing filtered searches over HNSW graphs.

This PR switches to utilizing that strategy by default as it generally provides a much better recall/latency pareto frontier than our regular hnsw fanout search.

Additionally, a new tech-preview setting is provided to potentially revert to the old fanout behavior if issues arise.
afoucret pushed a commit to afoucret/elasticsearch that referenced this pull request May 9, 2025
)

Apache Lucene 10.2 exposes a new search strategy for executing filtered searches over HNSW graphs.

This PR switches to utilizing that strategy by default as it generally provides a much better recall/latency pareto frontier than our regular hnsw fanout search.

Additionally, a new tech-preview setting is provided to potentially revert to the old fanout behavior if issues arise.
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request May 12, 2025
)

Apache Lucene 10.2 exposes a new search strategy for executing filtered searches over HNSW graphs.

This PR switches to utilizing that strategy by default as it generally provides a much better recall/latency pareto frontier than our regular hnsw fanout search.

Additionally, a new tech-preview setting is provided to potentially revert to the old fanout behavior if issues arise.
elasticsearchmachine pushed a commit that referenced this pull request Jun 16, 2025
Turns out when we have query cancellation checks turned on, we wrap the
filter bitset, meaning we cannot actually see that the inner Bits is a
bitset.

This is important for the hnsw knn format readers, see: 

https://github.com/apache/lucene/blob/1584c05b27ac31fbccb0ab328bf9f8eb6a7de414/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99HnswVectorsReader.java#L335

Related: #126876
@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
docs-missing-applies-tags PRs that are missing docs applies_to tags for an upcoming release. >enhancement :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants