jpountz commented on code in PR #13359:
URL: https://github.com/apache/lucene/pull/13359#discussion_r1609839123


##########
lucene/core/src/java/org/apache/lucene/search/TermQuery.java:
##########
@@ -150,7 +170,12 @@ public Scorer get(long leadCost) throws IOException {
 
         @Override
         public long cost() {
-          return docFreq;
+          try {
+            TermsEnum te = getTermsEnum();

Review Comment:
   Note that we were already getting a `TermsEnum` to be able to get the cost 
before, it just happened before creating the `ScorerSupplier`. So the 
additional cost here is the `if (termsEnum != null)` check under 
`getTermsEnum()`.
   
   Agreed that it's a pity to pull a terms enum only to get a cost, which is 
already encapsulated in the term state. Though I don't expect it to be a major 
issue in practice.



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

Reply via email to