Skip to content
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

Merged
merged 3 commits into from
Aug 4, 2020

Conversation

jtibshirani
Copy link
Member

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`.
Copy link
Contributor

@jpountz jpountz left a 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));
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@jtibshirani
Copy link
Member Author

Thanks for the review, I added another test and a changelog entry.

@jpountz jpountz merged commit b91a161 into apache:master Aug 4, 2020
@jtibshirani jtibshirani deleted the boolean-rewrite branch August 4, 2020 15:10
jpountz pushed a commit that referenced this pull request Aug 4, 2020
…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`.
@jpountz
Copy link
Contributor

jpountz commented Aug 4, 2020

FYI I backported to 8.7 and moved the CHANGES entry from 9.0 to 8.7.

gus-asf pushed a commit to gus-asf/lucene-solr that referenced this pull request Sep 4, 2020
…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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants