LUCENE-10439: Support multi-valued and multiple dimensions for count query in PointRangeQuery (#705)

This commit is contained in:
Lu Xugang 2022-02-24 17:13:03 +08:00 committed by GitHub
parent b0ca227862
commit 550d1305db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -387,15 +387,18 @@ public abstract class PointRangeQuery extends Query {
return 0;
}
if (reader.hasDeletions() == false
&& numDims == 1
&& values.getDocCount() == values.size()) {
// if all documents have at-most one point
if (reader.hasDeletions() == false) {
if (relate(values.getMinPackedValue(), values.getMaxPackedValue())
== Relation.CELL_INSIDE_QUERY) {
return values.getDocCount();
}
return (int) pointCount(values.getPointTree(), this::relate, this::matches);
// only 1D: we have the guarantee that it will actually run fast since there are at most 2
// crossing leaves.
// docCount == size : counting according number of points in leaf node, so must be
// single-valued.
if (numDims == 1 && values.getDocCount() == values.size()) {
return (int) pointCount(values.getPointTree(), this::relate, this::matches);
}
}
return super.count(context);
}