michaeljmarshall commented on PR #16578:
URL: https://github.com/apache/lucene/pull/16578#issuecomment-5483740070

   > We expect Query classes that match all docs to rewrite to 
MatchAllDocsQuery.INSTANCE to indicate that.
   
   For the following code, we get `new BoostQuery(new 
ConstantScoreQuery(MatchAllDocsQuery.INSTANCE), 0)` after rewrite: 
   
   ```
       BooleanQuery.Builder builder = new BooleanQuery.Builder();
       builder.add(MatchAllDocsQuery.INSTANCE, Occur.FILTER);
       BooleanQuery query = builder.build();
       IndexSearcher searcher = new IndexSearcher(new MultiReader());
       Query rewritten = searcher.rewrite(query);
   ```
   
   That's because the `BooleanQuery#rewrite` method wraps a single filter. 
Should I open a PR to add the following:
   
   ```java
             case FILTER:
               if (query.getClass() == MatchAllDocsQuery.class) {
                 return query;
               }
               // no scoring clauses, so return a score of 0
               return new BoostQuery(new ConstantScoreQuery(query), 0);
   ```
   
   > If they comply with this expectation, there's no need for a new method 
that indicates the same thing
   
   Agreed, no need for the abstraction if this is true.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to