LUCENE-10424: Optimize the "everything matches" case for count query in PointRangeQuery (#691)

This commit is contained in:
Lu Xugang 2022-02-21 14:08:23 +08:00 committed by GitHub
parent 76c9fd4e38
commit 36a2149d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -232,6 +232,8 @@ Optimizations
* LUCENE-10408 Better encoding of doc Ids in vectors. (Mayya Sharipova, Julie Tibshirani, Adrien Grand)
* LUCENE-10424 Optimize the "everything matches" case for count query in PointRangeQuery. (Ignacio Vera, Lu Xugang)
* LUCENE-10084: Rewrite DocValuesFieldExistsQuery to MatchAllDocsQuery whenever terms
or points have a docCount that is equal to maxDoc. (Vigya Sharma)

View File

@ -391,6 +391,10 @@ public abstract class PointRangeQuery extends Query {
&& numDims == 1
&& values.getDocCount() == values.size()) {
// if all documents have at-most one point
if (relate(values.getMinPackedValue(), values.getMaxPackedValue())
== Relation.CELL_INSIDE_QUERY) {
return values.getDocCount();
}
return (int) pointCount(values.getPointTree(), this::relate, this::matches);
}
return super.count(context);