Fix TestBooleanMinShouldMatch#testRandomQueries failure. #14715
Merged
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.