-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LUCENE-9446: In boolean rewrite, remove MatchAllDocsQuery filter clauses #1709
Conversation
Previously, we only removed 'match all' FILTER clauses if there was at least one MUST clause. Now they're also removed if there is another distinct FILTER clause. This lets boolean queries like `#field:value #*:*` be written to `#field:value`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks correct to me, I left a minor suggestion for a new test. Could you also add a CHANGES entry?
.build(); | ||
expected = new BoostQuery(new ConstantScoreQuery( | ||
new TermQuery(new Term("foo", "bar"))), 0.0f); | ||
assertEquals(expected, searcher.rewrite(bq)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also add a test for the case when there are two MatchAllDocsQuery
queries as filters with no MUST
clauses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks for the review, I added another test and a changelog entry. |
…ses (#1709) Previously, we only removed 'match all' FILTER clauses if there was at least one MUST clause. Now they're also removed if there is another distinct FILTER clause. This lets boolean queries like `#field:value #*:*` be written to `#field:value`.
FYI I backported to 8.7 and moved the CHANGES entry from 9.0 to 8.7. |
…ses (apache#1709) Previously, we only removed 'match all' FILTER clauses if there was at least one MUST clause. Now they're also removed if there is another distinct FILTER clause. This lets boolean queries like `#field:value #*:*` be written to `#field:value`.
Previously, we only removed 'match all' FILTER clauses if there was at least one
MUST clause. Now they're also removed if there is another distinct FILTER clause.
This lets boolean queries like
#field:value #*:*
be written to#field:value
.