Skip to content

Conversation

Mikep86
Copy link
Contributor

@Mikep86 Mikep86 commented Sep 18, 2025

Cleans up tests added in #132680. The rewrite tests in LinearRetrieverBuilderTests and RRFRetrieverBuilderTests are now aligned, testing the same scenarios in the same order. This should make these tests easier to maintain. The YAML tests have been adjusted to remove redundant tests and score checks that did not add value.

@Mikep86 Mikep86 added >test Issues or PRs that are addressing/adding tests :SearchOrg/Relevance Label for the Search (solution/org) Relevance team labels Sep 18, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search - Relevance The Search organization Search Relevance team label Sep 18, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Comment on lines -352 to -369
"Basic per-field boosting using the simplified format":
- requires:
cluster_features: ["rrf_retriever.simplified_weighted_support"]
reason: "Simplified weighted fields syntax support"

- do:
search:
index: test-index
body:
retriever:
rrf:
fields: [ "text_1", "text_2^2" ]
query: "foo"

# With weighted fields, verify basic functionality
- gte: { hits.total.value: 1 }
- length: { hits.hits: 1 }
# Verify that text_2^2 affects ranking (basic smoke test)
Copy link
Contributor Author

@Mikep86 Mikep86 Sep 18, 2025

Choose a reason for hiding this comment

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

This test is redundant, as we already have a test that applies per-field boosts to lexical matches and checks for changes in result order. Additionally, the assertions performed in this test do not meaningfully check that the boost actually was applied.

Comment on lines -624 to -639
"Semantic field weighting":
- requires:
cluster_features: ["rrf_retriever.simplified_weighted_support"]
reason: "Simplified weighted fields syntax support"

- do:
search:
index: test-index
body:
retriever:
rrf:
fields: ["dense_inference^2", "sparse_inference^1.5"]
query: "elasticsearch"

- match: { hits.total.value: 3 }
- length: { hits.hits: 3 }
Copy link
Contributor Author

@Mikep86 Mikep86 Sep 18, 2025

Choose a reason for hiding this comment

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

Comment on lines -335 to -349
"Zero weight handling":
- requires:
cluster_features: ["rrf_retriever.simplified_weighted_support"]
reason: "Simplified weighted fields syntax support"

- do:
search:
index: test-index
body:
retriever:
rrf:
fields: ["text_1^0", "text_2^1"]
query: "foo"

- gte: { hits.total.value: 1 }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have coverage for this in the rewrite tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RRF scores are generally not meaningful, hence why the existing tests did not check them. Moreover, the way they were being checked did not add any real value.

@Mikep86
Copy link
Contributor Author

Mikep86 commented Sep 19, 2025

@elasticmachine update branch

Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

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

Test looks good to me. The one piece of feedback that I have for the unit tests, is that it would be really helpful to add comments to the tests explaining why the scores are expected. Just to make it a little readable and parseable. Maybe that's something @mridula-s109 could help with in a followup if we agree it would be useful?

@mridula-s109
Copy link
Contributor

Test looks good to me. The one piece of feedback that I have for the unit tests, is that it would be really helpful to add comments to the tests explaining why the scores are expected. Just to make it a little readable and parseable. Maybe that's something @mridula-s109 could help with in a followup if we agree it would be useful?

Good point - adding comments to explain the expected scores would definitely make the tests more readable. I’m happy to take that up in a follow-up PR if everyone agrees.

@Mikep86
Copy link
Contributor Author

Mikep86 commented Sep 19, 2025

@kderusso

The one piece of feedback that I have for the unit tests, is that it would be really helpful to add comments to the tests explaining why the scores are expected

Do you mean the per-field boosts? We don't check document scores in the unit tests.

@kderusso
Copy link
Member

Do you mean the per-field boosts? We don't check document scores in the unit tests.

Sorry, yes, e.g. quickly explain why we would expect a boost of 3.75 on a combined field

@Mikep86 Mikep86 merged commit a375c6e into elastic:main Sep 19, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search - Relevance The Search organization Search Relevance team >test Issues or PRs that are addressing/adding tests v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants