gsmiller commented on code in PR #12055: URL: https://github.com/apache/lucene/pull/12055#discussion_r1109995482
########## lucene/core/src/java/org/apache/lucene/search/MultiTermQueryConstantScoreWrapper.java: ########## @@ -183,23 +182,31 @@ private WeightOrDocIdSet rewrite(LeafReaderContext context) throws IOException { } Query q = new ConstantScoreQuery(bq.build()); final Weight weight = searcher.rewrite(q).createWeight(searcher, scoreMode, score()); - return new WeightOrDocIdSet(weight); + return new WeightOrDocIdSetIterator(weight); } // Too many terms: go back to the terms we already collected and start building the bit set - DocIdSetBuilder builder = new DocIdSetBuilder(context.reader().maxDoc(), terms); + PriorityQueue<PostingsEnum> highFrequencyTerms = + new PriorityQueue<PostingsEnum>(collectedTerms.size()) { + @Override + protected boolean lessThan(PostingsEnum a, PostingsEnum b) { + return a.cost() < b.cost(); Review Comment: Looking at the internals of `insertWithOverflow`, I don't think we'll churn the smallest term here. If a later-visited term has the same cost as the top of the PQ, it will be rejected / immediately returned by `insertWithOverflow` and subsequently built into the bitset, which I think is what we want (to avoid unnecessary seeking later). Does that sound right? It's possible I'm missing something or misunderstanding the concern. -- 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