gsmiller commented on code in PR #13454: URL: https://github.com/apache/lucene/pull/13454#discussion_r1629951445
########## lucene/core/src/java/org/apache/lucene/search/AbstractMultiTermQueryConstantScoreWrapper.java: ########## @@ -162,21 +163,29 @@ private WeightOrDocIdSetIterator rewrite(LeafReaderContext context, Terms terms) assert termsEnum != null; final List<TermAndState> collectedTerms = new ArrayList<>(); - if (collectTerms(fieldDocCount, termsEnum, collectedTerms)) { - // build a boolean query - BooleanQuery.Builder bq = new BooleanQuery.Builder(); - for (TermAndState t : collectedTerms) { - final TermStates termStates = new TermStates(searcher.getTopReaderContext()); - termStates.register(t.state, context.ord, t.docFreq, t.totalTermFreq); - bq.add(new TermQuery(new Term(q.field, t.term), termStates), BooleanClause.Occur.SHOULD); - } - Query q = new ConstantScoreQuery(bq.build()); - final Weight weight = searcher.rewrite(q).createWeight(searcher, scoreMode, score()); - return new WeightOrDocIdSetIterator(weight); + boolean collectResult = collectTerms(fieldDocCount, termsEnum, collectedTerms); + if (collectResult && collectedTerms.size() == 0) { Review Comment: super minor: I tend to prefer `collectedTerms.isEmpty()` instead of `.size() == 0` as a slightly more idiomatic way to express this, but not a strong opinion :) Feel free to ignore. ########## lucene/CHANGES.txt: ########## @@ -249,7 +249,7 @@ Improvements Optimizations --------------------- -(No changes) +* GITHUB#13454: MultiTermQuery return null for ScoreSupplier (Mayya Sharipova) Review Comment: Maybe `MultiTermQuery returns null ScoreSupplier in cases where no query terms are present in the index segment` to avoid confusion? I initially read this as MultiTermQuery always returning null :) -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org