Fix TestBooleanMinShouldMatch#testRandomQueries failure.#14715
Merged
jpountz merged 1 commit intoapache:mainfrom May 31, 2025
Merged
Fix TestBooleanMinShouldMatch#testRandomQueries failure.#14715jpountz merged 1 commit intoapache:mainfrom
jpountz merged 1 commit intoapache:mainfrom
Conversation
This test generates random boolean queries and ensures that setting a minimum number of matching SHOULD clauses returns a subset of the hits with the same scores. It already tries to work around accuracy loss due to arithmetic operations by allowing a delta of up to one ulp between these two queries. However, sometimes the delta can be higher. For instance consider the following query that triggered the most recent test failure: `(data:5 data:5 data:5 data:6 +data:6 data:Z data:X -data:1)~2`. Without a minimum number of matching SHOULD clauses, it gets rewritten to `(data:5^3 +data:6^2 data:Z data:X -data:1)`. So the score contribution of `data:5` is computed as `(double) score(data:5) + (double) score(data:5) + (double) score(data:5)` in one case, and `(double) (score(data:5: * 3f)` (multiply first, then cast to a double) in the other case. The use of `ReqOptSumScorer` also contributes accuracy losses as per existing comment, for instance `data:6` is part of both the required and the optional clauses in the first case, while it's only a required clauses (with a 2x boost) in the other case. So accuracy loss accrues differently. I don't think we should try too hard to avoid these accuracy losses, so I'm instead increasing the leniency of the test.
Contributor
|
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog-check label to it and you will stop receiving this reminder on future updates to the PR. |
gf2121
approved these changes
May 26, 2025
uschindler
approved these changes
May 30, 2025
jpountz
added a commit
that referenced
this pull request
May 31, 2025
This test generates random boolean queries and ensures that setting a minimum number of matching SHOULD clauses returns a subset of the hits with the same scores. It already tries to work around accuracy loss due to arithmetic operations by allowing a delta of up to one ulp between these two queries. However, sometimes the delta can be higher. For instance consider the following query that triggered the most recent test failure: `(data:5 data:5 data:5 data:6 +data:6 data:Z data:X -data:1)~2`. Without a minimum number of matching SHOULD clauses, it gets rewritten to `(data:5^3 +data:6^2 data:Z data:X -data:1)`. So the score contribution of `data:5` is computed as `(double) score(data:5) + (double) score(data:5) + (double) score(data:5)` in one case, and `(double) (score(data:5: * 3f)` (multiply first, then cast to a double) in the other case. The use of `ReqOptSumScorer` also contributes accuracy losses as per existing comment, for instance `data:6` is part of both the required and the optional clauses in the first case, while it's only a required clauses (with a 2x boost) in the other case. So accuracy loss accrues differently. I don't think we should try too hard to avoid these accuracy losses, so I'm instead increasing the leniency of the test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This test generates random boolean queries and ensures that setting a minimum number of matching SHOULD clauses returns a subset of the hits with the same scores.
It already tries to work around accuracy loss due to arithmetic operations by allowing a delta of up to one ulp between these two queries. However, sometimes the delta can be higher.
For instance consider the following query that triggered the most recent test failure:
(data:5 data:5 data:5 data:6 +data:6 data:Z data:X -data:1)~2. Without a minimum number of matching SHOULD clauses, it gets rewritten to(data:5^3 +data:6^2 data:Z data:X -data:1). So the score contribution ofdata:5is computed as(double) score(data:5) + (double) score(data:5) + (double) score(data:5)in one case, and(double) (score(data:5: * 3f)(multiply first, then cast to a double) in the other case. The use ofReqOptSumScoreralso contributes accuracy losses as per existing comment, for instancedata:6is part of both the required and the optional clauses in the first case, while it's only a required clauses (with a 2x boost) in the other case. So accuracy loss accrues differently.I don't think we should try too hard to avoid these accuracy losses, so I'm instead increasing the leniency of the test.