You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "jpountz (via GitHub)" <gi...@apache.org> on 2023/07/20 13:29:19 UTC

[GitHub] [lucene] jpountz commented on a diff in pull request #12442: Assert IdxOrDvQuery subqueries and document useful fields

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


##########
lucene/test-framework/src/java/org/apache/lucene/tests/search/QueryUtils.java:
##########
@@ -675,7 +675,14 @@ public static void checkBulkScorerSkipTo(Random r, Query query, IndexSearcher se
     query = searcher.rewrite(query);
     Weight weight = searcher.createWeight(query, ScoreMode.COMPLETE, 1);
     for (LeafReaderContext context : searcher.getIndexReader().leaves()) {
-      final Scorer scorer = weight.scorer(context);
+      final Scorer scorer;
+      if (weight.scorerSupplier(context) != null) {
+        // For IndexOrDocValuesQuey, the bulk scorer will use the indexed structure query
+        // and the scorer with a lead cost of 0 will use the doc values query.
+        scorer = weight.scorerSupplier(context).get(0);
+      } else {
+        scorer = weight.scorer(context);

Review Comment:
   Should we set `scorer` to `null` here? A null `scorerSupplier` indicates no matches.
   
   ```suggestion
           scorer = null;
   ```



##########
lucene/test-framework/src/java/org/apache/lucene/tests/search/QueryUtils.java:
##########
@@ -675,7 +675,14 @@ public static void checkBulkScorerSkipTo(Random r, Query query, IndexSearcher se
     query = searcher.rewrite(query);
     Weight weight = searcher.createWeight(query, ScoreMode.COMPLETE, 1);
     for (LeafReaderContext context : searcher.getIndexReader().leaves()) {
-      final Scorer scorer = weight.scorer(context);
+      final Scorer scorer;
+      if (weight.scorerSupplier(context) != null) {
+        // For IndexOrDocValuesQuey, the bulk scorer will use the indexed structure query
+        // and the scorer with a lead cost of 0 will use the doc values query.
+        scorer = weight.scorerSupplier(context).get(0);

Review Comment:
   Let's call `scorerSupplier` only once as it could be expensive on queries that don't implement it directly since it delegates to `scorer`?



-- 
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-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org