Skip to content

Conversation

@ilariapet
Copy link
Contributor

@ilariapet ilariapet commented Sep 26, 2025

https://issues.apache.org/jira/browse/SOLR-17813

Description

Apache Lucene implemented a version of knn vector query called SeededKnnVectorQuery that provides a query seed to initiate the vector search (entry points in the HNSW graph exploration) based on Lexically-Accelerated Dense Retrieval

Solution

This PR introduces a new optional parameter for the current KNN query parser: seedQuery.
The seed parameter can be any valid Solr query, allowing traditional query logic to guide the vector search in a hybrid-like way.

Added a new method getSeedQuery() that parses the seed parameter and returns the corresponding Lucene Query.

When a seed query is present, the KNN vector query is wrapped with SeededKnnVectorQuery:

  • SeededKnnVectorQuery.fromFloatQuery(...) for FLOAT32 vectors.

  • SeededKnnVectorQuery.fromByteQuery(...) for BYTE vectors.

If no seedQuery is provided, the parser behaves as before and executes a "standard" KNN query.

Tests

  • Test to verify that when the seedQuery parameter is provided, the SeededKnnVectorQuery is executed (both float and byte).
  • Test to verify that when the seedQuery parameter is provided but blank, Solr throws a BAD_REQUEST exception.
  • Test to verify that when the seedQuery parameter is provided with an invalid value, Solr throws a BAD_REQUEST exception.
  • Test to verify that when the seedQuery parameter itself is a knn query, it is correctly parsed and applied as the seed for the main knn query.
  • Test to verify that when both seedQuery and early termination parameters are provided, the PatienceKnnVectorQuery is executed using the SeededKnnVectorQuery.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

Copy link
Contributor

@alessandrobenedetti alessandrobenedetti left a comment

Choose a reason for hiding this comment

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

Just reviewed in details, some minors Ila is going to solve, the PR is approved!

@ilariapet ilariapet marked this pull request as ready for review October 3, 2025 12:26
@alessandrobenedetti alessandrobenedetti merged commit 4f17dee into apache:main Oct 20, 2025
3 of 5 checks passed
alessandrobenedetti pushed a commit that referenced this pull request Oct 20, 2025
)

* support Lucene's (proposed) HNSW search seeding feature

Co-authored-by: Christine Poerschke <cpoerschke@apache.org>

(cherry picked from commit 4f17dee)
alessandrobenedetti pushed a commit that referenced this pull request Oct 21, 2025
)

* support Lucene's (proposed) HNSW search seeding feature

Co-authored-by: Christine Poerschke <cpoerschke@apache.org>

(cherry picked from commit 4f17dee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:schema cat:search documentation Improvements or additions to documentation tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants