LUCENE-10450: IndexSortSortedNumericDocValuesRangeQuery could be rewrite to MatchAllDocsQuery (#720)

This commit is contained in:
Lu Xugang 2022-03-02 16:28:40 +08:00 committed by Adrien Grand
parent c0d5022d5a
commit 1967942861
2 changed files with 6 additions and 0 deletions

View File

@ -201,6 +201,8 @@ Optimizations
* LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery
then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery. (Lu Xugang)
* LUCENE-10450: IndexSortSortedNumericDocValuesRangeQuery could be rewrite to MatchAllDocsQuery. (Lu Xugang)
Changes in runtime behavior
---------------------

View File

@ -30,6 +30,7 @@ import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.LeafFieldComparator;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.ScoreMode;
@ -140,6 +141,9 @@ public class IndexSortSortedNumericDocValuesRangeQuery extends Query {
}
Query rewrittenFallback = fallbackQuery.rewrite(reader);
if (rewrittenFallback.getClass() == MatchAllDocsQuery.class) {
return new MatchAllDocsQuery();
}
if (rewrittenFallback == fallbackQuery) {
return this;
} else {