[ 
https://issues.apache.org/jira/browse/LUCENE-6785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14736932#comment-14736932
 ] 

Terry Smith commented on LUCENE-6785:
-------------------------------------

The original patch drops a few key settings from the BooleanQuery in 
BQ.createWeight, the following patch puts them back and makes the tests happier.

{noformat}
diff --git a/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java 
b/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
index fb5f7c8..8dec338 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
@@ -210,7 +210,9 @@ public class BooleanQuery extends Query implements 
Iterable<BooleanClause> {
     }
 
     List<Weight> subweights = new ArrayList<>();
-    Builder builder = new Builder();
+    Builder builder = new Builder()
+      .setDisableCoord(disableCoord)
+      .setMinimumNumberShouldMatch(minimumNumberShouldMatch);
     for (BooleanClause clause : query) {
       Weight w = searcher.createWeight(clause.getQuery(), needsScores);
       subweights.add(w);
{noformat}


> Consider merging Query.rewrite() into Query.createWeight()
> ----------------------------------------------------------
>
>                 Key: LUCENE-6785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6785
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Alan Woodward
>         Attachments: LUCENE-6785.patch
>
>
> Prompted by the discussion on LUCENE-6590.
> Query.rewrite() is a bit of an oddity.  You call it to create a query for a 
> specific IndexSearcher, and to ensure that you get a query implementation 
> that has a working createWeight() method.  However, Weight itself already 
> encapsulates the notion of a per-searcher query.
> You also need to repeatedly call rewrite() until the query has stopped 
> rewriting itself, which is a bit trappy - there are a few places (in 
> highlighting code for example) that just call rewrite() once, rather than 
> looping round as IndexSearcher.rewrite() does.  Most queries don't need to be 
> called multiple times, however, so this seems a bit redundant.  And the ones 
> that do currently return un-rewritten queries can be changed simply enough to 
> rewrite them.
> Finally, in pretty much every case I can find in the codebase, rewrite() is 
> called purely as a prelude to createWeight().  This means, in the case of for 
> example large BooleanQueries, we end up cloning the whole query structure, 
> only to throw it away immediately.
> I'd like to try removing rewrite() entirely, and merging the logic into 
> createWeight(), simplifying the API and removing the trap where code only 
> calls rewrite once.  What do people think?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to