jpountz commented on a change in pull request #731:
URL: https://github.com/apache/lucene/pull/731#discussion_r839388337



##########
File path: 
lucene/sandbox/src/java/org/apache/lucene/sandbox/search/MultiRangeQuery.java
##########
@@ -314,6 +388,36 @@ public Scorer scorer(LeafReaderContext context) throws 
IOException {
       public boolean isCacheable(LeafReaderContext ctx) {
         return true;
       }
+
+      @Override
+      public int count(LeafReaderContext context) throws IOException {
+        if (numDims != 1 || context.reader().hasDeletions() == true) {
+          return super.count(context);
+        }
+        PointValues pointValues = context.reader().getPointValues(field);
+        if (pointValues == null || pointValues.size() != 
pointValues.getDocCount()) {
+          return super.count(context);
+        }
+        List<RangeClause> mergeRangeClause = 
mergeOverlappingRanges(rangeClauses, bytesPerDim);
+        int total = 0;
+        for (RangeClause rangeClause : mergeRangeClause) {
+          PointRangeQuery pointRangeQuery =
+              new PointRangeQuery(field, rangeClause.lowerValue, 
rangeClause.upperValue, numDims) {
+                @Override
+                protected String toString(int dimension, byte[] value) {
+                  return MultiRangeQuery.this.toString(dimension, value);
+                }
+              };
+          int count = pointRangeQuery.createWeight(searcher, scoreMode, 
boost).count(context);

Review comment:
       nit: I would not propagate the score mode since we know we do not need 
it here
   
   ```suggestion
             int count = pointRangeQuery.createWeight(searcher, 
ScoreMode.COMPLETE_NO_SCORES, 1f).count(context);
   ```

##########
File path: 
lucene/sandbox/src/java/org/apache/lucene/sandbox/search/MultiRangeQuery.java
##########
@@ -314,6 +388,36 @@ public Scorer scorer(LeafReaderContext context) throws 
IOException {
       public boolean isCacheable(LeafReaderContext ctx) {
         return true;
       }
+
+      @Override
+      public int count(LeafReaderContext context) throws IOException {
+        if (numDims != 1 || context.reader().hasDeletions() == true) {
+          return super.count(context);
+        }
+        PointValues pointValues = context.reader().getPointValues(field);
+        if (pointValues == null || pointValues.size() != 
pointValues.getDocCount()) {
+          return super.count(context);
+        }
+        List<RangeClause> mergeRangeClause = 
mergeOverlappingRanges(rangeClauses, bytesPerDim);

Review comment:
       We don't need this, it is required to call `rewrite` before creating a 
Weight, the ranges will already be merged when we reach this method.




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