Skip to content

Conversation

@benwtrent
Copy link
Member

@benwtrent benwtrent commented Mar 25, 2025

This allows a rescore_vector: {oversample: 0} to indicate bypassing oversampling and rescoring.

This is useful for:

  • Updating a quantized mapping to turn off automatic rescoring
  • Bypassing oversampling at query time in an ad-hoc manner if its on by default in the mapping

closes: #125157

@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Mar 25, 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.

if (oversampleValue == 0 && indexVersion.before(RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS)) {
throw new IllegalArgumentException("oversample must be greater than 1");
}
if (oversampleValue < 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel that I'm missing something obvious here, but 0 is now a valid value for oversampleValue in new index versions, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, let me verify I am capturing this accurately in tests. I might have removed an else if accidentally.

);

Query query = fieldType.createKnnQuery(VectorData.fromFloats(new float[] { 1, 4, 10 }), 10, 100, 0f, null, null, null);
assertTrue(query instanceof ESKnnFloatVectorQuery);
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to check that the query parameters do not include rescoring when 0 is used in the query. Also, we should probably check that we can't set 0 for previous index versions

Copy link
Member Author

Choose a reason for hiding this comment

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

++ I will add a test

Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

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

LGTM - Some comments on testing for your consideration

@benwtrent benwtrent added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Mar 26, 2025
@elasticsearchmachine elasticsearchmachine merged commit 009a86a into elastic:main Mar 26, 2025
17 checks passed
@benwtrent benwtrent deleted the feature/rescore-vector-zero-oversample branch March 26, 2025 19:57
omricohenn pushed a commit to omricohenn/elasticsearch that referenced this pull request Mar 28, 2025
…ample and rescoring (elastic#125599) This allows a `rescore_vector: {oversample: 0}` to indicate bypassing oversampling and rescoring. This is useful for: - Updating a quantized mapping to turn off automatic rescoring - Bypassing oversampling at query time in an ad-hoc manner if its on by default in the mapping closes: elastic#125157
@benwtrent
Copy link
Member Author

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request May 2, 2025
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request May 5, 2025
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request May 5, 2025
benwtrent added a commit that referenced this pull request May 5, 2025
blocks: #127662 This adds bwc versions for #125599
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request May 5, 2025
elasticsearchmachine pushed a commit that referenced this pull request May 5, 2025
…g oversample and rescoring (#125599) (#127662) * Allow zero for rescore_vector.oversample to indicate by-passing oversample and rescoring (#125599) This allows a `rescore_vector: {oversample: 0}` to indicate bypassing oversampling and rescoring. This is useful for: - Updating a quantized mapping to turn off automatic rescoring - Bypassing oversampling at query time in an ad-hoc manner if its on by default in the mapping closes: #125157 (cherry picked from commit 009a86a) * Adding versions for bwc for #125599 (#127663) blocks: #127662 This adds bwc versions for #125599 * fixing versioning for merge
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request May 9, 2025
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request May 12, 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

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) 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

6 participants