MultiTermQuery return null for ScoreSupplier#13454
Merged
mayya-sharipova merged 5 commits intoapache:mainfrom Jun 6, 2024
Merged
MultiTermQuery return null for ScoreSupplier#13454mayya-sharipova merged 5 commits intoapache:mainfrom
mayya-sharipova merged 5 commits intoapache:mainfrom
Conversation
MultiTermQuery return null for ScoreSupplier if there are no terms in an index that match query terms. With the introduction of PR apache#12156 we saw degradation in performance of bool queries where one of the mandatory clauses is a TermInSetQuery with query terms not present in the field. Before for such cases TermsInSetQuery returned null for ScoreSupplier which would shortcut the whole bool query. This PR adds ability for MultiTermQuery to return null for ScoreSupplier if a field doesn't contain any query terms. Relates to PR apache#12156
Contributor
Author
jpountz
reviewed
Jun 5, 2024
Contributor
jpountz
left a comment
There was a problem hiding this comment.
This is an interesting change. Instead of pushing the full cost of rewriting the query to ScorerSupplier#get, you are collecting the first 16 terms when calling Weight#scorerSupplier and the rest (potentially thousands of terms) when calling ScorerSupplier#get. This in-turn allows making better decisions for only a small amount of work pushed to Weight#scorerSupplier.
I left some style comments but I like the approach.
lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java
Outdated
Show resolved
Hide resolved
lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java
Show resolved
Hide resolved
Contributor
Author
|
@jpountz Thanks for your feedback, I addressed it, and the code looks much better with your suggestions! |
jpountz
approved these changes
Jun 6, 2024
gsmiller
approved these changes
Jun 6, 2024
Contributor
gsmiller
left a comment
There was a problem hiding this comment.
Seems like a reasonable change to me as well. Thanks!
lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java
Outdated
Show resolved
Hide resolved
mayya-sharipova
added a commit
that referenced
this pull request
Jun 6, 2024
MultiTermQuery return null for ScoreSupplier if there are no terms in an index that match query terms. With the introduction of PR #12156 we saw degradation in performance of bool queries where one of the mandatory clauses is a TermInSetQuery with query terms not present in the field. Before for such cases TermsInSetQuery returned null for ScoreSupplier which would shortcut the whole bool query. This PR adds ability for MultiTermQuery to return null for ScoreSupplier if a field doesn't contain any query terms. Relates to PR #12156
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.
MultiTermQuery return null for ScoreSupplier if there are no terms in an index that
match query terms.
With the introduction of PR #12156 we saw degradation in performance of bool queries where one of the mandatory clauses is a TermInSetQuery with query terms not present in the field. Before for such cases TermsInSetQuery returned null for ScoreSupplier which would shortcut the whole bool query.
This PR adds ability for MultiTermQuery to return null for ScoreSupplier if a field doesn't contain any query terms.
Relates to PR #12156