You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/08/03 17:24:39 UTC

[GitHub] [lucene-solr] jpountz commented on a change in pull request #1709: LUCENE-9446: In boolean rewrite, remove MatchAllDocsQuery filter clauses

jpountz commented on a change in pull request #1709:
URL: https://github.com/apache/lucene-solr/pull/1709#discussion_r464552982



##########
File path: lucene/core/src/test/org/apache/lucene/search/TestBooleanRewrites.java
##########
@@ -312,12 +312,20 @@ public void testRemoveMatchAllFilter() throws IOException {
         .add(new TermQuery(new Term("foo", "baz")), Occur.MUST)
         .add(new MatchAllDocsQuery(), Occur.FILTER)
         .build();
-    BooleanQuery expected = new BooleanQuery.Builder()
+    Query expected = new BooleanQuery.Builder()
         .setMinimumNumberShouldMatch(bq.getMinimumNumberShouldMatch())
         .add(new TermQuery(new Term("foo", "bar")), Occur.MUST)
         .add(new TermQuery(new Term("foo", "baz")), Occur.MUST)
         .build();
     assertEquals(expected, searcher.rewrite(bq));
+
+    bq = new BooleanQuery.Builder()
+            .add(new TermQuery(new Term("foo", "bar")), Occur.FILTER)
+            .add(new MatchAllDocsQuery(), Occur.FILTER)
+            .build();
+    expected = new BoostQuery(new ConstantScoreQuery(
+            new TermQuery(new Term("foo", "bar"))), 0.0f);
+    assertEquals(expected, searcher.rewrite(bq));

Review comment:
       maybe also add a test for the case when there are two `MatchAllDocsQuery` queries as filters with no `MUST` clauses?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org