wjp719 commented on a change in pull request #731: URL: https://github.com/apache/lucene/pull/731#discussion_r837001367
########## File path: lucene/sandbox/src/java/org/apache/lucene/sandbox/search/MultiRangeQuery.java ########## @@ -163,6 +165,69 @@ public void visit(QueryVisitor visitor) { } } + /** + * merge its overlapping ranges and return a simpler but slightly different form by calling {@link + * #mergeOverlappingRanges} + */ + @Override + public Query rewrite(IndexReader reader) throws IOException { + if (numDims != 1) { + return this; + } + List<RangeClause> mergedRanges = mergeOverlappingRanges(rangeClauses, bytesPerDim); + if (mergedRanges != rangeClauses) { + return new MultiRangeQuery(field, numDims, bytesPerDim, mergedRanges) { + @Override + protected String toString(int dimension, byte[] value) { + return MultiRangeQuery.this.toString(dimension, value); + } + }; + } else { + return this; + } + } + + /** merge overlapping ranges to some unconnected ranges */ + public static List<RangeClause> mergeOverlappingRanges( Review comment: done -- 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