Skip to content

Ref guide - Improve docs for Dense Vector reranking examples#4532

Open
adamjq wants to merge 1 commit into
apache:mainfrom
adamjq:docs/improve-vector-rerank-documentation
Open

Ref guide - Improve docs for Dense Vector reranking examples#4532
adamjq wants to merge 1 commit into
apache:mainfrom
adamjq:docs/improve-vector-rerank-documentation

Conversation

@adamjq

@adamjq adamjq commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

The Dense Vector Search page in the Solr Ref Guide currently has a section titled Usage in Re-Ranking Query. However, it only contains a single example of re-ranking with the KNN query parser which has an important caveat that this initiates a second pass full KNN query. While this is true, I think it may be confusing to readers as it's not the only supported option for re-ranking documents with vectors.

This PR adds documentation for the more efficient re-ranking feature that rerank subsets of documents by direct vector comparisons with the vectorSimilarity Function, with some notes about motivations and tradeoffs.

Solution

  • Moves indentation level of Usage in Re-Ranking Query in Dense Vector Search ref guide
  • Adds examples of how to use {!func}vectorSimilarity in a re-rank query
  • Adds note about reranking with Dense Vector Fields in Query Re-Ranking page

Before

solr_dense_vector_ref_guide_before

After

solr_dense_vector_ref_guide_changes

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
  • I have added a changelog entry for my change

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 16, 2026
@adamjq adamjq marked this pull request as ready for review June 17, 2026 18:10
@epugh epugh requested a review from Copilot June 19, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves the Solr Reference Guide documentation around dense vector re-ranking by clarifying that re-ranking can be done efficiently via vectorSimilarity() on a candidate set (instead of issuing a second full-index KNN pass), and cross-linking the relevant pages.

Changes:

  • Promoted/anchored the “Usage in Re-Ranking Query” section in dense-vector-search.adoc and added vectorSimilarity() re-ranking examples.
  • Added a cross-reference note in query-re-ranking.adoc pointing readers to dense vector re-ranking via vectorSimilarity().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
solr/solr-ref-guide/modules/query-guide/pages/query-re-ranking.adoc Adds a brief note linking to dense vector re-ranking via vectorSimilarity().
solr/solr-ref-guide/modules/query-guide/pages/dense-vector-search.adoc Adds a dedicated, anchored re-ranking section and examples for {!func}vectorSimilarity(...), plus notes on tradeoffs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +838 to +839
NOTE: The default `reRankOperator` is `add`, which sums the first-pass score and the vector similarity score.
Since these scores may differ in magnitude, you can adjust `reRankWeight` to control the balance between them, or use `reRankOperator=replace` to score re-ranked documents by vector similarity alone.
Comment on lines +841 to +845
When using a quantized vector field type (such as `ScalarQuantizedDenseVectorField`), the KNN first pass scores are computed on the quantized vectors.
Here is an example of re-ranking those results with exact float similarity scores, where `topK` matches `reRankDocs`:

[source,text]
?q={!knn f=vector topK=100}[1.0,2.0,3.0,4.0]&rq={!rerank reRankQuery=$rqq reRankDocs=100 reRankWeight=1 reRankOperator=replace}&rqq={!func}vectorSimilarity(vector,[1.0,2.0,3.0,4.0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants