LUCENE-10436: Remove deprecated DocValuesFieldExistsQuery, NormsFieldExistsQuery and KnnVectorFieldExistsQuery (#790)

This commit is contained in:
zacharymorn 2022-04-07 00:53:29 -07:00 committed by GitHub
parent f870edf2fe
commit 94fe7e314f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 79 additions and 184 deletions

View File

@ -22,6 +22,9 @@ API Changes
* LUCENE-10431: MultiTermQuery.setRewriteMethod() has been removed. (Alan Woodward)
* LUCENE-10436: Remove deprecated DocValuesFieldExistsQuery, NormsFieldExistsQuery and
KnnVectorFieldExistsQuery. (Zach Chen, Adrien Grand)
New Features
---------------------

View File

@ -25,6 +25,11 @@ These classes no longer take a `determinizeWorkLimit` and no longer determinize
behind the scenes. It is the responsibility of the caller to to call
`Operations.determinize()` for DFA execution.
### DocValuesFieldExistsQuery, NormsFieldExistsQuery and KnnVectorFieldExistsQuery removed in favor of FieldExistsQuery (LUCENE-10436)
These classes have been removed and consolidated into `FieldExistsQuery`. To migrate, caller simply replace those classes
with the new one during object instantiation.
## Migration from Lucene 9.0 to Lucene 9.1
### Test framework package migration and module (LUCENE-10301)

View File

@ -97,12 +97,11 @@ import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.lucene.index.VectorValues;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldDoc;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.KnnVectorQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.NormsFieldExistsQuery;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
@ -2132,10 +2131,10 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
private void searchExampleIndex(DirectoryReader reader) throws IOException {
IndexSearcher searcher = newSearcher(reader);
TopDocs topDocs = searcher.search(new NormsFieldExistsQuery("titleTokenized"), 10);
TopDocs topDocs = searcher.search(new FieldExistsQuery("titleTokenized"), 10);
assertEquals(50, topDocs.totalHits.value);
topDocs = searcher.search(new DocValuesFieldExistsQuery("titleDV"), 10);
topDocs = searcher.search(new FieldExistsQuery("titleDV"), 10);
assertEquals(50, topDocs.totalHits.value);
topDocs = searcher.search(new TermQuery(new Term("body", "ja")), 10);

View File

@ -26,7 +26,7 @@ import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.search.ConstantScoreScorer;
import org.apache.lucene.search.ConstantScoreWeight;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
@ -91,7 +91,7 @@ abstract class SortedNumericDocValuesRangeQuery extends Query {
@Override
public Query rewrite(IndexReader reader) throws IOException {
if (lowerValue == Long.MIN_VALUE && upperValue == Long.MAX_VALUE) {
return new DocValuesFieldExistsQuery(field);
return new FieldExistsQuery(field);
}
return super.rewrite(reader);
}

View File

@ -26,7 +26,7 @@ import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.search.ConstantScoreScorer;
import org.apache.lucene.search.ConstantScoreWeight;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
@ -105,7 +105,7 @@ abstract class SortedSetDocValuesRangeQuery extends Query {
@Override
public Query rewrite(IndexReader reader) throws IOException {
if (lowerValue == null && upperValue == null) {
return new DocValuesFieldExistsQuery(field);
return new FieldExistsQuery(field);
}
return super.rewrite(reader);
}

View File

@ -56,7 +56,6 @@ import org.apache.lucene.index.CheckIndex.Status.DocValuesStatus;
import org.apache.lucene.index.PointValues.IntersectVisitor;
import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.LeafFieldComparator;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
@ -4146,7 +4145,7 @@ public final class CheckIndex implements Closeable {
try {
int softDeletes =
PendingSoftDeletes.countSoftDeletes(
DocValuesFieldExistsQuery.getDocValuesDocIdSetIterator(softDeletesField, reader),
DocValuesIterator.getDocValuesDocIdSetIterator(softDeletesField, reader),
reader.getLiveDocs());
if (softDeletes != info.getSoftDelCount()) {
throw new CheckIndexException(

View File

@ -28,4 +28,40 @@ abstract class DocValuesIterator extends DocIdSetIterator {
* returns {@code target}.
*/
public abstract boolean advanceExact(int target) throws IOException;
/**
* Returns a {@link DocIdSetIterator} from the given field or null if the field doesn't exist in
* the reader or if the reader has no doc values for the field.
*/
public static DocIdSetIterator getDocValuesDocIdSetIterator(String field, LeafReader reader)
throws IOException {
FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field);
final DocIdSetIterator iterator;
if (fieldInfo != null) {
switch (fieldInfo.getDocValuesType()) {
case NONE:
iterator = null;
break;
case NUMERIC:
iterator = reader.getNumericDocValues(field);
break;
case BINARY:
iterator = reader.getBinaryDocValues(field);
break;
case SORTED:
iterator = reader.getSortedDocValues(field);
break;
case SORTED_NUMERIC:
iterator = reader.getSortedNumericDocValues(field);
break;
case SORTED_SET:
iterator = reader.getSortedSetDocValues(field);
break;
default:
throw new AssertionError();
}
return iterator;
}
return null;
}
}

View File

@ -59,7 +59,6 @@ import org.apache.lucene.internal.tests.IndexPackageAccess;
import org.apache.lucene.internal.tests.IndexWriterAccess;
import org.apache.lucene.internal.tests.TestSecrets;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
@ -3142,7 +3141,7 @@ public class IndexWriter
Bits liveDocs = leaf.getLiveDocs();
numSoftDeleted +=
PendingSoftDeletes.countSoftDeletes(
DocValuesFieldExistsQuery.getDocValuesDocIdSetIterator(
DocValuesIterator.getDocValuesDocIdSetIterator(
config.getSoftDeletesField(), leaf),
liveDocs);
}
@ -4848,8 +4847,7 @@ public class IndexWriter
int hardDeleteCount = 0;
int softDeletesCount = 0;
DocIdSetIterator softDeletedDocs =
DocValuesFieldExistsQuery.getDocValuesDocIdSetIterator(
config.getSoftDeletesField(), reader);
DocValuesIterator.getDocValuesDocIdSetIterator(config.getSoftDeletesField(), reader);
if (softDeletedDocs != null) {
int docId;
while ((docId = softDeletedDocs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {

View File

@ -21,7 +21,6 @@ import java.io.Closeable;
import java.io.IOException;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.Bits;
@ -78,7 +77,7 @@ final class PendingSoftDeletes extends PendingDeletes {
// only re-calculate this if we haven't seen this generation
if (dvGeneration < info.getDocValuesGen()) {
final DocIdSetIterator iterator =
DocValuesFieldExistsQuery.getDocValuesDocIdSetIterator(field, reader);
DocValuesIterator.getDocValuesDocIdSetIterator(field, reader);
int newDelCount;
if (iterator
!= null) { // nothing is deleted we don't have a soft deletes field in this segment

View File

@ -27,7 +27,6 @@ import java.util.Map;
import java.util.Objects;
import org.apache.lucene.document.Field;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.FixedBitSet;
@ -127,8 +126,7 @@ public final class SoftDeletesDirectoryReaderWrapper extends FilterDirectoryRead
}
static LeafReader wrap(LeafReader reader, String field) throws IOException {
DocIdSetIterator iterator =
DocValuesFieldExistsQuery.getDocValuesDocIdSetIterator(field, reader);
DocIdSetIterator iterator = DocValuesIterator.getDocValuesDocIdSetIterator(field, reader);
if (iterator == null) {
return reader;
}

View File

@ -23,7 +23,7 @@ import java.util.function.Supplier;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreMode;
@ -115,7 +115,7 @@ public final class SoftDeletesRetentionMergePolicy extends OneMergeWrappingMerge
},
reader.maxDoc() - reader.numDocs());
BooleanQuery.Builder builder = new BooleanQuery.Builder();
builder.add(new DocValuesFieldExistsQuery(softDeleteField), BooleanClause.Occur.FILTER);
builder.add(new FieldExistsQuery(softDeleteField), BooleanClause.Occur.FILTER);
builder.add(retentionQuery, BooleanClause.Occur.FILTER);
Scorer scorer = getScorer(builder.build(), wrappedReader);
if (scorer != null) {
@ -158,7 +158,7 @@ public final class SoftDeletesRetentionMergePolicy extends OneMergeWrappingMerge
final CodecReader reader = readerSupplier.get();
if (reader.getLiveDocs() != null) {
BooleanQuery.Builder builder = new BooleanQuery.Builder();
builder.add(new DocValuesFieldExistsQuery(field), BooleanClause.Occur.FILTER);
builder.add(new FieldExistsQuery(field), BooleanClause.Occur.FILTER);
builder.add(retentionQuerySupplier.get(), BooleanClause.Occur.FILTER);
Scorer scorer =
getScorer(

View File

@ -1,72 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene.search;
import java.io.IOException;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReader;
/**
* A {@link Query} that matches documents that have a value for a given field as reported by doc
* values iterators.
*
* @deprecated Use {@link org.apache.lucene.search.FieldExistsQuery} instead.
*/
@Deprecated
public final class DocValuesFieldExistsQuery extends FieldExistsQuery {
/** Create a query that will match documents which have a value for the given {@code field}. */
public DocValuesFieldExistsQuery(String field) {
super(field);
}
/**
* Returns a {@link DocIdSetIterator} from the given field or null if the field doesn't exist in
* the reader or if the reader has no doc values for the field.
*/
public static DocIdSetIterator getDocValuesDocIdSetIterator(String field, LeafReader reader)
throws IOException {
FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field);
final DocIdSetIterator iterator;
if (fieldInfo != null) {
switch (fieldInfo.getDocValuesType()) {
case NONE:
iterator = null;
break;
case NUMERIC:
iterator = reader.getNumericDocValues(field);
break;
case BINARY:
iterator = reader.getBinaryDocValues(field);
break;
case SORTED:
iterator = reader.getSortedDocValues(field);
break;
case SORTED_NUMERIC:
iterator = reader.getSortedNumericDocValues(field);
break;
case SORTED_SET:
iterator = reader.getSortedSetDocValues(field);
break;
default:
throw new AssertionError();
}
return iterator;
}
return null;
}
}

View File

@ -1,33 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene.search;
/**
* A {@link Query} that matches documents that contain a {@link
* org.apache.lucene.document.KnnVectorField}.
*
* @deprecated Use {@link org.apache.lucene.search.FieldExistsQuery} instead.
*/
@Deprecated
public class KnnVectorFieldExistsQuery extends FieldExistsQuery {
/** Create a query that will match documents which have a value for the given {@code field}. */
public KnnVectorFieldExistsQuery(String field) {
super(field);
}
}

View File

@ -99,7 +99,7 @@ public class KnnVectorQuery extends Query {
BooleanQuery booleanQuery =
new BooleanQuery.Builder()
.add(filter, BooleanClause.Occur.FILTER)
.add(new KnnVectorFieldExistsQuery(field), BooleanClause.Occur.FILTER)
.add(new FieldExistsQuery(field), BooleanClause.Occur.FILTER)
.build();
indexSearcher.search(booleanQuery, filterCollector);
}

View File

@ -1,34 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene.search;
import org.apache.lucene.document.StringField;
/**
* A {@link Query} that matches documents that have a value for a given field as reported by field
* norms. This will not work for fields that omit norms, e.g. {@link StringField}.
*
* @deprecated Use {@link org.apache.lucene.search.FieldExistsQuery} instead.
*/
@Deprecated
public final class NormsFieldExistsQuery extends FieldExistsQuery {
/** Create a query that will match that have a value for the given {@code field}. */
public NormsFieldExistsQuery(String field) {
super(field);
}
}

View File

@ -58,9 +58,8 @@ public class UsageTrackingQueryCachingPolicy implements QueryCachingPolicy {
return true;
}
if (query instanceof DocValuesFieldExistsQuery) {
// We do not bother caching DocValuesFieldExistsQuery queries since they are already plenty
// fast.
if (query instanceof FieldExistsQuery) {
// We do not bother caching FieldExistsQuery queries since they are already plenty fast.
return true;
}

View File

@ -34,7 +34,7 @@ import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@ -674,7 +674,7 @@ public class TestMixedDocValuesUpdates extends LuceneTestCase {
try (DirectoryReader reader = DirectoryReader.open(writer)) {
IndexSearcher searcher = new IndexSearcher(reader);
TopDocs is_live = searcher.search(new DocValuesFieldExistsQuery("is_live"), 5);
TopDocs is_live = searcher.search(new FieldExistsQuery("is_live"), 5);
assertEquals(numHits, is_live.totalHits.value);
for (ScoreDoc doc : is_live.scoreDocs) {
int id = Integer.parseInt(reader.document(doc.doc).get("id"));

View File

@ -35,7 +35,7 @@ import org.apache.lucene.document.IntPoint;
import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
@ -126,9 +126,7 @@ public class TestSoftDeletesRetentionMergePolicy extends LuceneTestCase {
assertEquals(1, reader.leaves().size());
MergePolicy policy =
new SoftDeletesRetentionMergePolicy(
"soft_delete",
() -> new DocValuesFieldExistsQuery("keep_around"),
NoMergePolicy.INSTANCE);
"soft_delete", () -> new FieldExistsQuery("keep_around"), NoMergePolicy.INSTANCE);
assertFalse(
policy.keepFullyDeletedSegment(() -> (SegmentReader) reader.leaves().get(0).reader()));
reader.close();
@ -496,7 +494,7 @@ public class TestSoftDeletesRetentionMergePolicy extends LuceneTestCase {
config.setReaderPooling(true);
config.setMergePolicy(
new SoftDeletesRetentionMergePolicy(
"soft_delete", () -> new DocValuesFieldExistsQuery("keep"), new LogDocMergePolicy()));
"soft_delete", () -> new FieldExistsQuery("keep"), new LogDocMergePolicy()));
IndexWriter writer = new IndexWriter(dir, config);
writer
.getConfig()

View File

@ -57,7 +57,7 @@ public class TestUsageTrackingFilterCachingPolicy extends LuceneTestCase {
}
public void testNeverCacheDocValuesFieldExistsFilter() throws IOException {
Query q = new DocValuesFieldExistsQuery("foo");
Query q = new FieldExistsQuery("foo");
UsageTrackingQueryCachingPolicy policy = new UsageTrackingQueryCachingPolicy();
for (int i = 0; i < 1000; ++i) {
policy.onUse(q);

View File

@ -22,8 +22,8 @@ import org.apache.lucene.document.DoublePoint;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.DoubleValuesSource;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
@ -51,7 +51,7 @@ public class TestDoubleRangeGroupSelector extends BaseGroupSelectorTestCase<Doub
if (groupValue == null) {
return new BooleanQuery.Builder()
.add(new MatchAllDocsQuery(), BooleanClause.Occur.FILTER)
.add(new DocValuesFieldExistsQuery("double"), BooleanClause.Occur.MUST_NOT)
.add(new FieldExistsQuery("double"), BooleanClause.Occur.MUST_NOT)
.build();
}
return DoublePoint.newRangeQuery("double", groupValue.min, Math.nextDown(groupValue.max));

View File

@ -22,7 +22,7 @@ import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.LongValuesSource;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
@ -51,7 +51,7 @@ public class TestLongRangeGroupSelector extends BaseGroupSelectorTestCase<LongRa
if (groupValue == null) {
return new BooleanQuery.Builder()
.add(new MatchAllDocsQuery(), BooleanClause.Occur.FILTER)
.add(new DocValuesFieldExistsQuery("long"), BooleanClause.Occur.MUST_NOT)
.add(new FieldExistsQuery("long"), BooleanClause.Occur.MUST_NOT)
.build();
}
return LongPoint.newRangeQuery("long", groupValue.min, groupValue.max - 1);

View File

@ -24,7 +24,7 @@ import org.apache.lucene.document.TextField;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
@ -52,7 +52,7 @@ public class TestTermGroupSelector extends BaseGroupSelectorTestCase<BytesRef> {
if (groupValue == null) {
return new BooleanQuery.Builder()
.add(new MatchAllDocsQuery(), BooleanClause.Occur.FILTER)
.add(new DocValuesFieldExistsQuery("groupField"), BooleanClause.Occur.MUST_NOT)
.add(new FieldExistsQuery("groupField"), BooleanClause.Occur.MUST_NOT)
.build();
}
return new TermQuery(new Term("groupField", groupValue));

View File

@ -559,7 +559,7 @@ public class TestJoinUtil extends LuceneTestCase {
static Query numericDocValuesScoreQuery(final String field) {
return new Query() {
private final Query fieldQuery = new DocValuesFieldExistsQuery(field);
private final Query fieldQuery = new FieldExistsQuery(field);
@Override
public Weight createWeight(

View File

@ -28,8 +28,8 @@ import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.search.ConstantScoreScorer;
import org.apache.lucene.search.ConstantScoreWeight;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.LeafFieldComparator;
import org.apache.lucene.search.MatchAllDocsQuery;
@ -143,7 +143,7 @@ public class IndexSortSortedNumericDocValuesRangeQuery extends Query {
@Override
public Query rewrite(IndexReader reader) throws IOException {
if (lowerValue == Long.MIN_VALUE && upperValue == Long.MAX_VALUE) {
return new DocValuesFieldExistsQuery(field);
return new FieldExistsQuery(field);
}
Query rewrittenFallback = fallbackQuery.rewrite(reader);

View File

@ -30,7 +30,7 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
@ -371,7 +371,7 @@ public class TestIndexSortSortedNumericDocValuesRangeQuery extends LuceneTestCas
Query query = createQuery("field", Long.MIN_VALUE, Long.MAX_VALUE);
Query rewrittenQuery = query.rewrite(reader);
assertEquals(new DocValuesFieldExistsQuery("field"), rewrittenQuery);
assertEquals(new FieldExistsQuery("field"), rewrittenQuery);
writer.close();
reader.close();