Ban oal.search.Filter.
Filter has been deprecated in Lucene 5.4 and will be removed in 6.0. We should stop using this API.
This commit is contained in:
parent
6d3dd727c2
commit
57310fc451
|
@ -23,12 +23,9 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queries.BlendedTermQuery;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.MultiPhraseQuery;
|
||||
import org.apache.lucene.search.PhraseQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.spans.SpanTermQuery;
|
||||
import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
|
||||
|
@ -65,9 +62,6 @@ public class CustomFieldQuery extends FieldQuery {
|
|||
flatten(((ConstantScoreQuery) sourceQuery).getQuery(), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof FunctionScoreQuery) {
|
||||
flatten(((FunctionScoreQuery) sourceQuery).getSubQuery(), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof FilteredQuery) {
|
||||
flatten(((FilteredQuery) sourceQuery).getQuery(), reader, flatQueries, boost);
|
||||
flatten(((FilteredQuery) sourceQuery).getFilter(), reader, flatQueries);
|
||||
} else if (sourceQuery instanceof MultiPhrasePrefixQuery) {
|
||||
flatten(sourceQuery.rewrite(reader), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof FiltersFunctionScoreQuery) {
|
||||
|
@ -120,14 +114,4 @@ public class CustomFieldQuery extends FieldQuery {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void flatten(Filter sourceFilter, IndexReader reader, Collection<Query> flatQueries) throws IOException {
|
||||
Boolean highlight = highlightFilters.get();
|
||||
if (highlight == null || highlight.equals(Boolean.FALSE)) {
|
||||
return;
|
||||
}
|
||||
if (sourceFilter instanceof QueryWrapperFilter) {
|
||||
flatten(((QueryWrapperFilter) sourceFilter).getQuery(), reader, flatQueries, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,12 +43,12 @@ public class Queries {
|
|||
return new BooleanQuery.Builder().build();
|
||||
}
|
||||
|
||||
public static Filter newNestedFilter() {
|
||||
return new QueryWrapperFilter(new PrefixQuery(new Term(TypeFieldMapper.NAME, new BytesRef("__"))));
|
||||
public static Query newNestedFilter() {
|
||||
return new PrefixQuery(new Term(TypeFieldMapper.NAME, new BytesRef("__")));
|
||||
}
|
||||
|
||||
public static Filter newNonNestedFilter() {
|
||||
return new QueryWrapperFilter(not(newNestedFilter()));
|
||||
public static Query newNonNestedFilter() {
|
||||
return not(newNestedFilter());
|
||||
}
|
||||
|
||||
public static BooleanQuery filtered(@Nullable Query query, @Nullable Query filter) {
|
||||
|
@ -101,8 +101,6 @@ public class Queries {
|
|||
public static boolean isConstantMatchAllQuery(Query query) {
|
||||
if (query instanceof ConstantScoreQuery) {
|
||||
return isConstantMatchAllQuery(((ConstantScoreQuery) query).getQuery());
|
||||
} else if (query instanceof QueryWrapperFilter) {
|
||||
return isConstantMatchAllQuery(((QueryWrapperFilter) query).getQuery());
|
||||
} else if (query instanceof MatchAllDocsQuery) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
package org.elasticsearch.index.fielddata;
|
||||
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.FieldComparatorSource;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.Weight;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
import org.apache.lucene.util.BitDocIdSet;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
|
@ -123,9 +123,9 @@ public interface IndexFieldData<FD extends AtomicFieldData> extends IndexCompone
|
|||
public static class Nested {
|
||||
|
||||
private final BitSetProducer rootFilter;
|
||||
private final Filter innerFilter;
|
||||
private final Weight innerFilter;
|
||||
|
||||
public Nested(BitSetProducer rootFilter, Filter innerFilter) {
|
||||
public Nested(BitSetProducer rootFilter, Weight innerFilter) {
|
||||
this.rootFilter = rootFilter;
|
||||
this.innerFilter = innerFilter;
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ public interface IndexFieldData<FD extends AtomicFieldData> extends IndexCompone
|
|||
/**
|
||||
* Get a {@link DocIdSet} that matches the inner documents.
|
||||
*/
|
||||
public DocIdSet innerDocs(LeafReaderContext ctx) throws IOException {
|
||||
return innerFilter.getDocIdSet(ctx, null);
|
||||
public DocIdSetIterator innerDocs(LeafReaderContext ctx) throws IOException {
|
||||
return innerFilter.scorer(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.index.RandomAccessOrds;
|
||||
import org.apache.lucene.index.SortedDocValues;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.FieldComparator;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.apache.lucene.search.SortField;
|
||||
|
@ -95,7 +95,7 @@ public class BytesRefFieldComparatorSource extends IndexFieldData.XFieldComparat
|
|||
selectedValues = sortMode.select(values);
|
||||
} else {
|
||||
final BitSet rootDocs = nested.rootDocs(context);
|
||||
final DocIdSet innerDocs = nested.innerDocs(context);
|
||||
final DocIdSetIterator innerDocs = nested.innerDocs(context);
|
||||
selectedValues = sortMode.select(values, rootDocs, innerDocs);
|
||||
}
|
||||
if (sortMissingFirst(missingValue) || sortMissingLast(missingValue)) {
|
||||
|
@ -125,7 +125,7 @@ public class BytesRefFieldComparatorSource extends IndexFieldData.XFieldComparat
|
|||
selectedValues = sortMode.select(values, nonNullMissingBytes);
|
||||
} else {
|
||||
final BitSet rootDocs = nested.rootDocs(context);
|
||||
final DocIdSet innerDocs = nested.innerDocs(context);
|
||||
final DocIdSetIterator innerDocs = nested.innerDocs(context);
|
||||
selectedValues = sortMode.select(values, nonNullMissingBytes, rootDocs, innerDocs, context.reader().maxDoc());
|
||||
}
|
||||
return selectedValues;
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.elasticsearch.index.fielddata.fieldcomparator;
|
|||
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.index.NumericDocValues;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.FieldComparator;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.apache.lucene.search.SortField;
|
||||
|
@ -79,7 +79,7 @@ public class DoubleValuesComparatorSource extends IndexFieldData.XFieldComparato
|
|||
selectedValues = sortMode.select(values, dMissingValue);
|
||||
} else {
|
||||
final BitSet rootDocs = nested.rootDocs(context);
|
||||
final DocIdSet innerDocs = nested.innerDocs(context);
|
||||
final DocIdSetIterator innerDocs = nested.innerDocs(context);
|
||||
selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
|
||||
}
|
||||
return selectedValues.getRawDoubleValues();
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.elasticsearch.index.fielddata.fieldcomparator;
|
|||
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.index.NumericDocValues;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.FieldComparator;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
|
@ -71,7 +71,7 @@ public class FloatValuesComparatorSource extends IndexFieldData.XFieldComparator
|
|||
selectedValues = sortMode.select(values, dMissingValue);
|
||||
} else {
|
||||
final BitSet rootDocs = nested.rootDocs(context);
|
||||
final DocIdSet innerDocs = nested.innerDocs(context);
|
||||
final DocIdSetIterator innerDocs = nested.innerDocs(context);
|
||||
selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
|
||||
}
|
||||
return selectedValues.getRawFloatValues();
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.index.NumericDocValues;
|
||||
import org.apache.lucene.index.SortedNumericDocValues;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.FieldComparator;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
|
@ -70,7 +71,7 @@ public class LongValuesComparatorSource extends IndexFieldData.XFieldComparatorS
|
|||
selectedValues = sortMode.select(values, dMissingValue);
|
||||
} else {
|
||||
final BitSet rootDocs = nested.rootDocs(context);
|
||||
final DocIdSet innerDocs = nested.innerDocs(context);
|
||||
final DocIdSetIterator innerDocs = nested.innerDocs(context);
|
||||
selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
|
||||
}
|
||||
return selectedValues;
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
package org.elasticsearch.index.mapper;
|
||||
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Weight;
|
||||
import org.elasticsearch.ElasticsearchGenerationException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
@ -330,17 +329,14 @@ public class DocumentMapper implements ToXContent {
|
|||
continue;
|
||||
}
|
||||
|
||||
Filter filter = objectMapper.nestedTypeFilter();
|
||||
Query filter = objectMapper.nestedTypeFilter();
|
||||
if (filter == null) {
|
||||
continue;
|
||||
}
|
||||
// We can pass down 'null' as acceptedDocs, because nestedDocId is a doc to be fetched and
|
||||
// therefor is guaranteed to be a live doc.
|
||||
DocIdSet nestedTypeSet = filter.getDocIdSet(context, null);
|
||||
if (nestedTypeSet == null) {
|
||||
continue;
|
||||
}
|
||||
DocIdSetIterator iterator = nestedTypeSet.iterator();
|
||||
final Weight nestedWeight = filter.createWeight(sc.searcher(), false);
|
||||
DocIdSetIterator iterator = nestedWeight.scorer(context);
|
||||
if (iterator == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
package org.elasticsearch.index.mapper.object;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
|
@ -324,7 +323,7 @@ public class ObjectMapper extends Mapper implements AllFieldMapper.IncludeInAll,
|
|||
private final String nestedTypePathAsString;
|
||||
private final BytesRef nestedTypePathAsBytes;
|
||||
|
||||
private final Filter nestedTypeFilter;
|
||||
private final Query nestedTypeFilter;
|
||||
|
||||
private volatile Dynamic dynamic;
|
||||
|
||||
|
@ -348,7 +347,7 @@ public class ObjectMapper extends Mapper implements AllFieldMapper.IncludeInAll,
|
|||
}
|
||||
this.nestedTypePathAsString = "__" + fullPath;
|
||||
this.nestedTypePathAsBytes = new BytesRef(nestedTypePathAsString);
|
||||
this.nestedTypeFilter = new QueryWrapperFilter(new TermQuery(new Term(TypeFieldMapper.NAME, nestedTypePathAsBytes)));
|
||||
this.nestedTypeFilter = new TermQuery(new Term(TypeFieldMapper.NAME, nestedTypePathAsBytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -432,7 +431,7 @@ public class ObjectMapper extends Mapper implements AllFieldMapper.IncludeInAll,
|
|||
return this.nested;
|
||||
}
|
||||
|
||||
public Filter nestedTypeFilter() {
|
||||
public Query nestedTypeFilter() {
|
||||
return this.nestedTypeFilter;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
|
@ -187,7 +186,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
|
|||
throw new IllegalStateException("[" + NAME + "] nested object under path [" + path + "] is not of nested type");
|
||||
}
|
||||
final BitSetProducer parentFilter;
|
||||
final Filter childFilter;
|
||||
final Query childFilter;
|
||||
final ObjectMapper parentObjectMapper;
|
||||
final Query innerQuery;
|
||||
ObjectMapper objectMapper = context.nestedScope().getObjectMapper();
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index.query;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.queryparser.classic.MapperQueryParser;
|
||||
import org.apache.lucene.queryparser.classic.QueryParserSettings;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
import org.apache.lucene.search.similarities.Similarity;
|
||||
|
@ -177,7 +176,7 @@ public class QueryShardContext {
|
|||
return queryParser;
|
||||
}
|
||||
|
||||
public BitSetProducer bitsetFilter(Filter filter) {
|
||||
public BitSetProducer bitsetFilter(Query filter) {
|
||||
return indexQueryParser.bitsetFilterCache.getBitSetProducer(filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.query.support;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -56,7 +55,7 @@ public class NestedInnerQueryParseSupport {
|
|||
protected boolean filterFound = false;
|
||||
|
||||
protected BitSetProducer parentFilter;
|
||||
protected Filter childFilter;
|
||||
protected Query childFilter;
|
||||
|
||||
protected ObjectMapper nestedObjectMapper;
|
||||
private ObjectMapper parentObjectMapper;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
package org.elasticsearch.search;
|
||||
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
import org.apache.lucene.util.Bits;
|
||||
|
@ -571,12 +570,8 @@ public enum MultiValueMode implements Writeable<MultiValueMode> {
|
|||
* NOTE: Calling the returned instance on docs that are not root docs is illegal
|
||||
* The returned instance can only be evaluate the current and upcoming docs
|
||||
*/
|
||||
public NumericDocValues select(final SortedNumericDocValues values, final long missingValue, final BitSet rootDocs, final DocIdSet innerDocSet, int maxDoc) throws IOException {
|
||||
if (rootDocs == null || innerDocSet == null) {
|
||||
return select(DocValues.emptySortedNumeric(maxDoc), missingValue);
|
||||
}
|
||||
final DocIdSetIterator innerDocs = innerDocSet.iterator();
|
||||
if (innerDocs == null) {
|
||||
public NumericDocValues select(final SortedNumericDocValues values, final long missingValue, final BitSet rootDocs, final DocIdSetIterator innerDocs, int maxDoc) throws IOException {
|
||||
if (rootDocs == null || innerDocs == null) {
|
||||
return select(DocValues.emptySortedNumeric(maxDoc), missingValue);
|
||||
}
|
||||
|
||||
|
@ -666,12 +661,8 @@ public enum MultiValueMode implements Writeable<MultiValueMode> {
|
|||
* NOTE: Calling the returned instance on docs that are not root docs is illegal
|
||||
* The returned instance can only be evaluate the current and upcoming docs
|
||||
*/
|
||||
public NumericDoubleValues select(final SortedNumericDoubleValues values, final double missingValue, final BitSet rootDocs, final DocIdSet innerDocSet, int maxDoc) throws IOException {
|
||||
if (rootDocs == null || innerDocSet == null) {
|
||||
return select(FieldData.emptySortedNumericDoubles(maxDoc), missingValue);
|
||||
}
|
||||
final DocIdSetIterator innerDocs = innerDocSet.iterator();
|
||||
if (innerDocs == null) {
|
||||
public NumericDoubleValues select(final SortedNumericDoubleValues values, final double missingValue, final BitSet rootDocs, final DocIdSetIterator innerDocs, int maxDoc) throws IOException {
|
||||
if (rootDocs == null || innerDocs == null) {
|
||||
return select(FieldData.emptySortedNumericDoubles(maxDoc), missingValue);
|
||||
}
|
||||
|
||||
|
@ -761,12 +752,8 @@ public enum MultiValueMode implements Writeable<MultiValueMode> {
|
|||
* NOTE: Calling the returned instance on docs that are not root docs is illegal
|
||||
* The returned instance can only be evaluate the current and upcoming docs
|
||||
*/
|
||||
public BinaryDocValues select(final SortedBinaryDocValues values, final BytesRef missingValue, final BitSet rootDocs, final DocIdSet innerDocSet, int maxDoc) throws IOException {
|
||||
if (rootDocs == null || innerDocSet == null) {
|
||||
return select(FieldData.emptySortedBinary(maxDoc), missingValue);
|
||||
}
|
||||
final DocIdSetIterator innerDocs = innerDocSet.iterator();
|
||||
if (innerDocs == null) {
|
||||
public BinaryDocValues select(final SortedBinaryDocValues values, final BytesRef missingValue, final BitSet rootDocs, final DocIdSetIterator innerDocs, int maxDoc) throws IOException {
|
||||
if (rootDocs == null || innerDocs == null) {
|
||||
return select(FieldData.emptySortedBinary(maxDoc), missingValue);
|
||||
}
|
||||
final BinaryDocValues selectedValues = select(values, null);
|
||||
|
@ -861,12 +848,8 @@ public enum MultiValueMode implements Writeable<MultiValueMode> {
|
|||
* NOTE: Calling the returned instance on docs that are not root docs is illegal
|
||||
* The returned instance can only be evaluate the current and upcoming docs
|
||||
*/
|
||||
public SortedDocValues select(final RandomAccessOrds values, final BitSet rootDocs, final DocIdSet innerDocSet) throws IOException {
|
||||
if (rootDocs == null || innerDocSet == null) {
|
||||
return select(DocValues.emptySortedSet());
|
||||
}
|
||||
final DocIdSetIterator innerDocs = innerDocSet.iterator();
|
||||
if (innerDocs == null) {
|
||||
public SortedDocValues select(final RandomAccessOrds values, final BitSet rootDocs, final DocIdSetIterator innerDocs) throws IOException {
|
||||
if (rootDocs == null || innerDocs == null) {
|
||||
return select(DocValues.emptySortedSet());
|
||||
}
|
||||
final SortedDocValues selectedValues = select(values);
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
*/
|
||||
package org.elasticsearch.search.aggregations.bucket.children;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.fielddata.plain.ParentChildIndexFieldData;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
|
@ -75,8 +74,8 @@ public class ChildrenParser implements Aggregator.Parser {
|
|||
DocumentMapper childDocMapper = context.mapperService().documentMapper(childType);
|
||||
|
||||
String parentType = null;
|
||||
Filter parentFilter = null;
|
||||
Filter childFilter = null;
|
||||
Query parentFilter = null;
|
||||
Query childFilter = null;
|
||||
if (childDocMapper != null) {
|
||||
ParentFieldMapper parentFieldMapper = childDocMapper.parentFieldMapper();
|
||||
if (!parentFieldMapper.active()) {
|
||||
|
@ -86,8 +85,8 @@ public class ChildrenParser implements Aggregator.Parser {
|
|||
DocumentMapper parentDocMapper = context.mapperService().documentMapper(parentType);
|
||||
if (parentDocMapper != null) {
|
||||
// TODO: use the query API
|
||||
parentFilter = new QueryWrapperFilter(parentDocMapper.typeFilter());
|
||||
childFilter = new QueryWrapperFilter(childDocMapper.typeFilter());
|
||||
parentFilter = parentDocMapper.typeFilter();
|
||||
childFilter = childDocMapper.typeFilter();
|
||||
ParentChildIndexFieldData parentChildIndexFieldData = context.fieldData().getForField(parentFieldMapper.fieldType());
|
||||
config.fieldContext(new FieldContext(parentFieldMapper.fieldType().names().indexName(), parentChildIndexFieldData, parentFieldMapper.fieldType()));
|
||||
} else {
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ParentToChildrenAggregator extends SingleBucketAggregator {
|
|||
private Set<LeafReaderContext> replay = new LinkedHashSet<>();
|
||||
|
||||
public ParentToChildrenAggregator(String name, AggregatorFactories factories, AggregationContext aggregationContext,
|
||||
Aggregator parent, String parentType, Filter childFilter, Filter parentFilter,
|
||||
Aggregator parent, String parentType, Query childFilter, Query parentFilter,
|
||||
ValuesSource.Bytes.WithOrdinals.ParentChild valuesSource,
|
||||
long maxOrd, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
|
||||
super(name, factories, aggregationContext, parent, pipelineAggregators, metaData);
|
||||
|
@ -185,10 +185,10 @@ public class ParentToChildrenAggregator extends SingleBucketAggregator {
|
|||
public static class Factory extends ValuesSourceAggregatorFactory<ValuesSource.Bytes.WithOrdinals.ParentChild> {
|
||||
|
||||
private final String parentType;
|
||||
private final Filter parentFilter;
|
||||
private final Filter childFilter;
|
||||
private final Query parentFilter;
|
||||
private final Query childFilter;
|
||||
|
||||
public Factory(String name, ValuesSourceConfig<ValuesSource.Bytes.WithOrdinals.ParentChild> config, String parentType, Filter parentFilter, Filter childFilter) {
|
||||
public Factory(String name, ValuesSourceConfig<ValuesSource.Bytes.WithOrdinals.ParentChild> config, String parentType, Query parentFilter, Query childFilter) {
|
||||
super(name, InternalChildren.TYPE.name(), config);
|
||||
this.parentType = parentType;
|
||||
this.parentFilter = parentFilter;
|
||||
|
|
|
@ -21,9 +21,9 @@ package org.elasticsearch.search.fetch;
|
|||
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.index.ReaderUtil;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Weight;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -353,7 +353,7 @@ public class FetchPhase implements SearchPhase {
|
|||
String originalName = nestedObjectMapper.name();
|
||||
InternalSearchHit.InternalNestedIdentity nestedIdentity = null;
|
||||
do {
|
||||
Filter parentFilter;
|
||||
Query parentFilter;
|
||||
nestedParentObjectMapper = documentMapper.findParentObjectMapper(current);
|
||||
if (nestedParentObjectMapper != null) {
|
||||
if (nestedParentObjectMapper.nested().isNested() == false) {
|
||||
|
@ -365,18 +365,13 @@ public class FetchPhase implements SearchPhase {
|
|||
parentFilter = Queries.newNonNestedFilter();
|
||||
}
|
||||
|
||||
Filter childFilter = nestedObjectMapper.nestedTypeFilter();
|
||||
Query childFilter = nestedObjectMapper.nestedTypeFilter();
|
||||
if (childFilter == null) {
|
||||
current = nestedParentObjectMapper;
|
||||
continue;
|
||||
}
|
||||
// We can pass down 'null' as acceptedDocs, because we're fetching matched docId that matched in the query phase.
|
||||
DocIdSet childDocSet = childFilter.getDocIdSet(subReaderContext, null);
|
||||
if (childDocSet == null) {
|
||||
current = nestedParentObjectMapper;
|
||||
continue;
|
||||
}
|
||||
DocIdSetIterator childIter = childDocSet.iterator();
|
||||
final Weight childWeight = context.searcher().createNormalizedWeight(childFilter, false);
|
||||
DocIdSetIterator childIter = childWeight.scorer(subReaderContext);
|
||||
if (childIter == null) {
|
||||
current = nestedParentObjectMapper;
|
||||
continue;
|
||||
|
|
|
@ -110,14 +110,14 @@ public final class InnerHitsContext {
|
|||
|
||||
@Override
|
||||
public TopDocs topDocs(SearchContext context, FetchSubPhase.HitContext hitContext) throws IOException {
|
||||
Filter rawParentFilter;
|
||||
Query rawParentFilter;
|
||||
if (parentObjectMapper == null) {
|
||||
rawParentFilter = Queries.newNonNestedFilter();
|
||||
} else {
|
||||
rawParentFilter = parentObjectMapper.nestedTypeFilter();
|
||||
}
|
||||
BitSetProducer parentFilter = context.bitsetFilterCache().getBitSetProducer(rawParentFilter);
|
||||
Filter childFilter = childObjectMapper.nestedTypeFilter();
|
||||
Query childFilter = childObjectMapper.nestedTypeFilter();
|
||||
Query q = Queries.filtered(query.query(), new NestedChildrenQuery(parentFilter, childFilter, hitContext));
|
||||
|
||||
if (size() == 0) {
|
||||
|
@ -147,11 +147,11 @@ public final class InnerHitsContext {
|
|||
static class NestedChildrenQuery extends Query {
|
||||
|
||||
private final BitSetProducer parentFilter;
|
||||
private final Filter childFilter;
|
||||
private final Query childFilter;
|
||||
private final int docId;
|
||||
private final LeafReader leafReader;
|
||||
|
||||
NestedChildrenQuery(BitSetProducer parentFilter, Filter childFilter, FetchSubPhase.HitContext hitContext) {
|
||||
NestedChildrenQuery(BitSetProducer parentFilter, Query childFilter, FetchSubPhase.HitContext hitContext) {
|
||||
this.parentFilter = parentFilter;
|
||||
this.childFilter = childFilter;
|
||||
this.docId = hitContext.docId();
|
||||
|
@ -187,6 +187,7 @@ public final class InnerHitsContext {
|
|||
|
||||
@Override
|
||||
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
|
||||
final Weight childWeight = childFilter.createWeight(searcher, false);
|
||||
return new ConstantScoreWeight(this) {
|
||||
@Override
|
||||
public Scorer scorer(LeafReaderContext context) throws IOException {
|
||||
|
@ -208,11 +209,7 @@ public final class InnerHitsContext {
|
|||
return null;
|
||||
}
|
||||
|
||||
final DocIdSet children = childFilter.getDocIdSet(context, null);
|
||||
if (children == null) {
|
||||
return null;
|
||||
}
|
||||
final DocIdSetIterator childrenIterator = children.iterator();
|
||||
final DocIdSetIterator childrenIterator = childWeight.scorer(context);
|
||||
if (childrenIterator == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.search.highlight;
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.highlight.QueryScorer;
|
||||
import org.apache.lucene.search.highlight.WeightedSpanTerm;
|
||||
|
@ -83,9 +82,6 @@ public final class CustomQueryScorer extends QueryScorer {
|
|||
} else if (query instanceof FiltersFunctionScoreQuery) {
|
||||
query = ((FiltersFunctionScoreQuery) query).getSubQuery();
|
||||
extract(query, query.getBoost(), terms);
|
||||
} else if (query instanceof FilteredQuery) {
|
||||
query = ((FilteredQuery) query).getQuery();
|
||||
extract(query, 1F, terms);
|
||||
} else {
|
||||
extractWeightedTerms(terms, query, query.getBoost());
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.elasticsearch.search.internal;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.util.Counter;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
|
@ -83,7 +83,7 @@ public class SubSearchContext extends FilteredSearchContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Filter searchFilter(String[] types) {
|
||||
public Query searchFilter(String[] types) {
|
||||
throw new UnsupportedOperationException("this context should be read only");
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,9 @@ package org.elasticsearch.search.sort;
|
|||
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.index.NumericDocValues;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.FieldComparator;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
|
@ -171,14 +170,14 @@ public class GeoDistanceSortParser implements SortParser {
|
|||
final Nested nested;
|
||||
if (nestedHelper != null && nestedHelper.getPath() != null) {
|
||||
BitSetProducer rootDocumentsFilter = context.bitsetFilterCache().getBitSetProducer(Queries.newNonNestedFilter());
|
||||
Filter innerDocumentsFilter;
|
||||
Query innerDocumentsFilter;
|
||||
if (nestedHelper.filterFound()) {
|
||||
// TODO: use queries instead
|
||||
innerDocumentsFilter = new QueryWrapperFilter(nestedHelper.getInnerFilter());
|
||||
innerDocumentsFilter = nestedHelper.getInnerFilter();
|
||||
} else {
|
||||
innerDocumentsFilter = nestedHelper.getNestedObjectMapper().nestedTypeFilter();
|
||||
}
|
||||
nested = new Nested(rootDocumentsFilter, innerDocumentsFilter);
|
||||
nested = new Nested(rootDocumentsFilter, context.searcher().createNormalizedWeight(innerDocumentsFilter, false));
|
||||
} else {
|
||||
nested = null;
|
||||
}
|
||||
|
@ -202,7 +201,7 @@ public class GeoDistanceSortParser implements SortParser {
|
|||
selectedValues = finalSortMode.select(distanceValues, Double.MAX_VALUE);
|
||||
} else {
|
||||
final BitSet rootDocs = nested.rootDocs(context);
|
||||
final DocIdSet innerDocs = nested.innerDocs(context);
|
||||
final DocIdSetIterator innerDocs = nested.innerDocs(context);
|
||||
selectedValues = finalSortMode.select(distanceValues, Double.MAX_VALUE, rootDocs, innerDocs, context.reader().maxDoc());
|
||||
}
|
||||
return selectedValues.getRawDoubleValues();
|
||||
|
|
|
@ -21,8 +21,7 @@ package org.elasticsearch.search.sort;
|
|||
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
|
@ -145,14 +144,14 @@ public class ScriptSortParser implements SortParser {
|
|||
final Nested nested;
|
||||
if (nestedHelper != null && nestedHelper.getPath() != null) {
|
||||
BitSetProducer rootDocumentsFilter = context.bitsetFilterCache().getBitSetProducer(Queries.newNonNestedFilter());
|
||||
Filter innerDocumentsFilter;
|
||||
Query innerDocumentsFilter;
|
||||
if (nestedHelper.filterFound()) {
|
||||
// TODO: use queries instead
|
||||
innerDocumentsFilter = new QueryWrapperFilter(nestedHelper.getInnerFilter());
|
||||
innerDocumentsFilter = nestedHelper.getInnerFilter();
|
||||
} else {
|
||||
innerDocumentsFilter = nestedHelper.getNestedObjectMapper().nestedTypeFilter();
|
||||
}
|
||||
nested = new Nested(rootDocumentsFilter, innerDocumentsFilter);
|
||||
nested = new Nested(rootDocumentsFilter, context.searcher().createNormalizedWeight(innerDocumentsFilter, false));
|
||||
} else {
|
||||
nested = null;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
package org.elasticsearch.search.sort;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
|
@ -240,14 +239,14 @@ public class SortParseElement implements SearchParseElement {
|
|||
final Nested nested;
|
||||
if (nestedHelper != null && nestedHelper.getPath() != null) {
|
||||
BitSetProducer rootDocumentsFilter = context.bitsetFilterCache().getBitSetProducer(Queries.newNonNestedFilter());
|
||||
Filter innerDocumentsFilter;
|
||||
Query innerDocumentsFilter;
|
||||
if (nestedHelper.filterFound()) {
|
||||
// TODO: use queries instead
|
||||
innerDocumentsFilter = new QueryWrapperFilter(nestedHelper.getInnerFilter());
|
||||
innerDocumentsFilter = nestedHelper.getInnerFilter();
|
||||
} else {
|
||||
innerDocumentsFilter = nestedHelper.getNestedObjectMapper().nestedTypeFilter();
|
||||
}
|
||||
nested = new Nested(rootDocumentsFilter, innerDocumentsFilter);
|
||||
nested = new Nested(rootDocumentsFilter, context.searcher().createNormalizedWeight(innerDocumentsFilter, false));
|
||||
} else {
|
||||
nested = null;
|
||||
}
|
||||
|
|
|
@ -32,9 +32,7 @@ import org.apache.lucene.index.IndexableField;
|
|||
import org.apache.lucene.index.NoMergePolicy;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queries.TermsQuery;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
|
@ -67,7 +65,7 @@ public class FreqTermsEnumTests extends ESTestCase {
|
|||
private Map<String, FreqHolder> referenceAll;
|
||||
private Map<String, FreqHolder> referenceNotDeleted;
|
||||
private Map<String, FreqHolder> referenceFilter;
|
||||
private Filter filter;
|
||||
private Query filter;
|
||||
|
||||
static class FreqHolder {
|
||||
int docFreq;
|
||||
|
@ -153,7 +151,7 @@ public class FreqTermsEnumTests extends ESTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
filter = new QueryWrapperFilter(new TermsQuery(filterTerms));
|
||||
filter = new TermsQuery(filterTerms);
|
||||
}
|
||||
|
||||
private void addFreqs(Document doc, Map<String, FreqHolder> reference) {
|
||||
|
|
|
@ -31,10 +31,8 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.index.LogByteSizeMergePolicy;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Accountable;
|
||||
import org.apache.lucene.util.BitSet;
|
||||
|
@ -90,7 +88,7 @@ public class BitSetFilterCacheTests extends ESTestCase {
|
|||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
|
||||
BitsetFilterCache cache = new BitsetFilterCache(new Index("test"), Settings.EMPTY);
|
||||
BitSetProducer filter = cache.getBitSetProducer(new QueryWrapperFilter(new TermQuery(new Term("field", "value"))));
|
||||
BitSetProducer filter = cache.getBitSetProducer(new TermQuery(new Term("field", "value")));
|
||||
assertThat(matchCount(filter, reader), equalTo(3));
|
||||
|
||||
// now cached
|
||||
|
@ -160,7 +158,7 @@ public class BitSetFilterCacheTests extends ESTestCase {
|
|||
}
|
||||
}
|
||||
});
|
||||
BitSetProducer filter = cache.getBitSetProducer(new QueryWrapperFilter(new TermQuery(new Term("field", "value"))));
|
||||
BitSetProducer filter = cache.getBitSetProducer(new TermQuery(new Term("field", "value")));
|
||||
assertThat(matchCount(filter, reader), equalTo(1));
|
||||
assertTrue(stats.get() > 0);
|
||||
assertEquals(1, onCacheCalls.get());
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,6 +44,8 @@ import org.elasticsearch.test.ESSingleNodeTestCase;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
@ -130,9 +134,9 @@ public abstract class AbstractFieldDataTestCase extends ESSingleNodeTestCase {
|
|||
writer.close();
|
||||
}
|
||||
|
||||
protected Nested createNested(Filter parentFilter, Filter childFilter) {
|
||||
protected Nested createNested(IndexSearcher searcher, Query parentFilter, Query childFilter) throws IOException {
|
||||
BitsetFilterCache s = indexService.bitsetFilterCache();
|
||||
return new Nested(s.getBitSetProducer(parentFilter), childFilter);
|
||||
return new Nested(s.getBitSetProducer(parentFilter), searcher.createNormalizedWeight(childFilter, false));
|
||||
}
|
||||
|
||||
public void testEmpty() throws Exception {
|
||||
|
|
|
@ -27,16 +27,15 @@ import org.apache.lucene.document.Field.Store;
|
|||
import org.apache.lucene.document.SortedSetDocValuesField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopFieldDocs;
|
||||
import org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter;
|
||||
import org.apache.lucene.search.join.QueryBitSetProducer;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.apache.lucene.util.Accountable;
|
||||
|
@ -402,11 +401,11 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI
|
|||
missingValue = new BytesRef(TestUtil.randomSimpleString(getRandom()));
|
||||
break;
|
||||
}
|
||||
Filter parentFilter = new QueryWrapperFilter(new TermQuery(new Term("type", "parent")));
|
||||
Filter childFilter = new QueryWrapperFilter(Queries.not(parentFilter));
|
||||
Nested nested = createNested(parentFilter, childFilter);
|
||||
Query parentFilter = new TermQuery(new Term("type", "parent"));
|
||||
Query childFilter = Queries.not(parentFilter);
|
||||
Nested nested = createNested(searcher, parentFilter, childFilter);
|
||||
BytesRefFieldComparatorSource nestedComparatorSource = new BytesRefFieldComparatorSource(fieldData, missingValue, sortMode, nested);
|
||||
ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
|
||||
ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
|
||||
Sort sort = new Sort(new SortField("text", nestedComparatorSource));
|
||||
TopFieldDocs topDocs = searcher.search(query, randomIntBetween(1, numParents), sort);
|
||||
assertTrue(topDocs.scoreDocs.length > 0);
|
||||
|
|
|
@ -24,19 +24,16 @@ import org.apache.lucene.document.StringField;
|
|||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.FieldDoc;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.TopFieldDocs;
|
||||
import org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter;
|
||||
import org.apache.lucene.search.join.QueryBitSetProducer;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
|
@ -217,10 +214,10 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
|
|||
|
||||
MultiValueMode sortMode = MultiValueMode.SUM;
|
||||
IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, false));
|
||||
Filter parentFilter = new QueryWrapperFilter(new TermQuery(new Term("__type", "parent")));
|
||||
Filter childFilter = new QueryWrapperFilter(Queries.not(parentFilter));
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, null, createNested(parentFilter, childFilter));
|
||||
ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
|
||||
Query parentFilter = new TermQuery(new Term("__type", "parent"));
|
||||
Query childFilter = Queries.not(parentFilter);
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, null, createNested(searcher, parentFilter, childFilter));
|
||||
ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
|
||||
|
||||
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
|
||||
TopFieldDocs topDocs = searcher.search(query, 5, sort);
|
||||
|
@ -252,11 +249,11 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
|
|||
assertThat(topDocs.scoreDocs[4].doc, equalTo(3));
|
||||
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(9));
|
||||
|
||||
childFilter = new QueryWrapperFilter(new TermQuery(new Term("filter_1", "T")));
|
||||
nestedComparatorSource = createFieldComparator("field2", sortMode, null, createNested(parentFilter, childFilter));
|
||||
childFilter = new TermQuery(new Term("filter_1", "T"));
|
||||
nestedComparatorSource = createFieldComparator("field2", sortMode, null, createNested(searcher, parentFilter, childFilter));
|
||||
query = new ToParentBlockJoinQuery(
|
||||
new FilteredQuery(new MatchAllDocsQuery(), childFilter),
|
||||
new BitDocIdSetCachingWrapperFilter(parentFilter),
|
||||
new ConstantScoreQuery(childFilter),
|
||||
new QueryBitSetProducer(parentFilter),
|
||||
ScoreMode.None
|
||||
);
|
||||
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
|
||||
|
@ -289,7 +286,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
|
|||
assertThat(topDocs.scoreDocs[4].doc, equalTo(3));
|
||||
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(9));
|
||||
|
||||
nestedComparatorSource = createFieldComparator("field2", sortMode, 127, createNested(parentFilter, childFilter));
|
||||
nestedComparatorSource = createFieldComparator("field2", sortMode, 127, createNested(searcher, parentFilter, childFilter));
|
||||
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
|
||||
topDocs = searcher.search(new TermQuery(new Term("__type", "parent")), 5, sort);
|
||||
assertThat(topDocs.totalHits, equalTo(8));
|
||||
|
@ -305,7 +302,7 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
|
|||
assertThat(topDocs.scoreDocs[4].doc, equalTo(7));
|
||||
assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(8));
|
||||
|
||||
nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(parentFilter, childFilter));
|
||||
nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(searcher, parentFilter, childFilter));
|
||||
sort = new Sort(new SortField("field2", nestedComparatorSource));
|
||||
topDocs = searcher.search(new TermQuery(new Term("__type", "parent")), 5, sort);
|
||||
assertThat(topDocs.totalHits, equalTo(8));
|
||||
|
@ -327,11 +324,11 @@ public abstract class AbstractNumberNestedSortingTestCase extends AbstractFieldD
|
|||
searcher.getIndexReader().close();
|
||||
}
|
||||
|
||||
protected void assertAvgScoreMode(Filter parentFilter, IndexSearcher searcher) throws IOException {
|
||||
protected void assertAvgScoreMode(Query parentFilter, IndexSearcher searcher) throws IOException {
|
||||
MultiValueMode sortMode = MultiValueMode.AVG;
|
||||
Filter childFilter = new QueryWrapperFilter(Queries.not(parentFilter));
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(parentFilter, childFilter));
|
||||
Query query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
|
||||
Query childFilter = Queries.not(parentFilter);
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(searcher, parentFilter, childFilter));
|
||||
Query query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
|
||||
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
|
||||
TopDocs topDocs = searcher.search(query, 5, sort);
|
||||
assertThat(topDocs.totalHits, equalTo(7));
|
||||
|
|
|
@ -21,17 +21,14 @@ package org.elasticsearch.index.search.nested;
|
|||
import org.apache.lucene.document.DoubleField;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.FieldDoc;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter;
|
||||
import org.apache.lucene.search.join.QueryBitSetProducer;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
|
@ -68,11 +65,11 @@ public class DoubleNestedSortingTests extends AbstractNumberNestedSortingTestCas
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void assertAvgScoreMode(Filter parentFilter, IndexSearcher searcher) throws IOException {
|
||||
protected void assertAvgScoreMode(Query parentFilter, IndexSearcher searcher) throws IOException {
|
||||
MultiValueMode sortMode = MultiValueMode.AVG;
|
||||
Filter childFilter = new QueryWrapperFilter(Queries.not(parentFilter));
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(parentFilter, childFilter));
|
||||
Query query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
|
||||
Query childFilter = Queries.not(parentFilter);
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(searcher, parentFilter, childFilter));
|
||||
Query query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
|
||||
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
|
||||
TopDocs topDocs = searcher.search(query, 5, sort);
|
||||
assertThat(topDocs.totalHits, equalTo(7));
|
||||
|
|
|
@ -21,17 +21,14 @@ package org.elasticsearch.index.search.nested;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FloatField;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.FieldDoc;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter;
|
||||
import org.apache.lucene.search.join.QueryBitSetProducer;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
|
@ -67,11 +64,11 @@ public class FloatNestedSortingTests extends DoubleNestedSortingTests {
|
|||
return new FloatField(name, value, store);
|
||||
}
|
||||
|
||||
protected void assertAvgScoreMode(Filter parentFilter, IndexSearcher searcher, IndexFieldData.XFieldComparatorSource innerFieldComparator) throws IOException {
|
||||
protected void assertAvgScoreMode(Query parentFilter, IndexSearcher searcher, IndexFieldData.XFieldComparatorSource innerFieldComparator) throws IOException {
|
||||
MultiValueMode sortMode = MultiValueMode.AVG;
|
||||
Filter childFilter = new QueryWrapperFilter(Queries.not(parentFilter));
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(parentFilter, childFilter));
|
||||
Query query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
|
||||
Query childFilter = Queries.not(parentFilter);
|
||||
XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(searcher, parentFilter, childFilter));
|
||||
Query query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
|
||||
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
|
||||
TopDocs topDocs = searcher.search(query, 5, sort);
|
||||
assertThat(topDocs.totalHits, equalTo(7));
|
||||
|
|
|
@ -28,18 +28,14 @@ import org.apache.lucene.search.BooleanClause.Occur;
|
|||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.FieldDoc;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.TopFieldDocs;
|
||||
import org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter;
|
||||
import org.apache.lucene.search.join.QueryBitSetProducer;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -118,9 +114,9 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
|
|||
}
|
||||
|
||||
private TopDocs getTopDocs(IndexSearcher searcher, IndexFieldData<?> indexFieldData, String missingValue, MultiValueMode sortMode, int n, boolean reverse) throws IOException {
|
||||
Filter parentFilter = new QueryWrapperFilter(new TermQuery(new Term("__type", "parent")));
|
||||
Filter childFilter = new QueryWrapperFilter(new TermQuery(new Term("__type", "child")));
|
||||
XFieldComparatorSource nestedComparatorSource = indexFieldData.comparatorSource(missingValue, sortMode, createNested(parentFilter, childFilter));
|
||||
Query parentFilter = new TermQuery(new Term("__type", "parent"));
|
||||
Query childFilter = new TermQuery(new Term("__type", "child"));
|
||||
XFieldComparatorSource nestedComparatorSource = indexFieldData.comparatorSource(missingValue, sortMode, createNested(searcher, parentFilter, childFilter));
|
||||
Query query = new ConstantScoreQuery(parentFilter);
|
||||
Sort sort = new Sort(new SortField("f", nestedComparatorSource, reverse));
|
||||
return searcher.search(query, n, sort);
|
||||
|
@ -284,10 +280,10 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
|
|||
MultiValueMode sortMode = MultiValueMode.MIN;
|
||||
IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, false));
|
||||
PagedBytesIndexFieldData indexFieldData = getForField("field2");
|
||||
Filter parentFilter = new QueryWrapperFilter(new TermQuery(new Term("__type", "parent")));
|
||||
Filter childFilter = new QueryWrapperFilter(Queries.not(parentFilter));
|
||||
BytesRefFieldComparatorSource nestedComparatorSource = new BytesRefFieldComparatorSource(indexFieldData, null, sortMode, createNested(parentFilter, childFilter));
|
||||
ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
|
||||
Query parentFilter = new TermQuery(new Term("__type", "parent"));
|
||||
Query childFilter = Queries.not(parentFilter);
|
||||
BytesRefFieldComparatorSource nestedComparatorSource = new BytesRefFieldComparatorSource(indexFieldData, null, sortMode, createNested(searcher, parentFilter, childFilter));
|
||||
ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
|
||||
|
||||
Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
|
||||
TopFieldDocs topDocs = searcher.search(query, 5, sort);
|
||||
|
@ -305,7 +301,7 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
|
|||
assertThat(((BytesRef) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).utf8ToString(), equalTo("i"));
|
||||
|
||||
sortMode = MultiValueMode.MAX;
|
||||
nestedComparatorSource = new BytesRefFieldComparatorSource(indexFieldData, null, sortMode, createNested(parentFilter, childFilter));
|
||||
nestedComparatorSource = new BytesRefFieldComparatorSource(indexFieldData, null, sortMode, createNested(searcher, parentFilter, childFilter));
|
||||
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
|
||||
topDocs = searcher.search(query, 5, sort);
|
||||
assertThat(topDocs.totalHits, equalTo(7));
|
||||
|
@ -325,11 +321,11 @@ public class NestedSortingTests extends AbstractFieldDataTestCase {
|
|||
BooleanQuery.Builder bq = new BooleanQuery.Builder();
|
||||
bq.add(parentFilter, Occur.MUST_NOT);
|
||||
bq.add(new TermQuery(new Term("filter_1", "T")), Occur.MUST);
|
||||
childFilter = new QueryWrapperFilter(bq.build());
|
||||
nestedComparatorSource = new BytesRefFieldComparatorSource(indexFieldData, null, sortMode, createNested(parentFilter, childFilter));
|
||||
childFilter = bq.build();
|
||||
nestedComparatorSource = new BytesRefFieldComparatorSource(indexFieldData, null, sortMode, createNested(searcher, parentFilter, childFilter));
|
||||
query = new ToParentBlockJoinQuery(
|
||||
new FilteredQuery(new MatchAllDocsQuery(), childFilter),
|
||||
new BitDocIdSetCachingWrapperFilter(parentFilter),
|
||||
new ConstantScoreQuery(childFilter),
|
||||
new QueryBitSetProducer(parentFilter),
|
||||
ScoreMode.None
|
||||
);
|
||||
sort = new Sort(new SortField("field2", nestedComparatorSource, true));
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.search;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
|
||||
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.util.BitDocIdSet;
|
||||
import org.apache.lucene.util.BitSetIterator;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.FixedBitSet;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
|
@ -170,7 +171,7 @@ public class MultiValueModeTests extends ESTestCase {
|
|||
private void verify(SortedNumericDocValues values, int maxDoc, FixedBitSet rootDocs, FixedBitSet innerDocs) throws IOException {
|
||||
for (long missingValue : new long[] { 0, randomLong() }) {
|
||||
for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX, MultiValueMode.SUM, MultiValueMode.AVG}) {
|
||||
final NumericDocValues selected = mode.select(values, missingValue, rootDocs, new BitDocIdSet(innerDocs), maxDoc);
|
||||
final NumericDocValues selected = mode.select(values, missingValue, rootDocs, new BitSetIterator(innerDocs, 0L), maxDoc);
|
||||
int prevRoot = -1;
|
||||
for (int root = rootDocs.nextSetBit(0); root != -1; root = root + 1 < maxDoc ? rootDocs.nextSetBit(root + 1) : -1) {
|
||||
final long actual = selected.get(root);
|
||||
|
@ -320,7 +321,7 @@ public class MultiValueModeTests extends ESTestCase {
|
|||
private void verify(SortedNumericDoubleValues values, int maxDoc, FixedBitSet rootDocs, FixedBitSet innerDocs) throws IOException {
|
||||
for (long missingValue : new long[] { 0, randomLong() }) {
|
||||
for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX, MultiValueMode.SUM, MultiValueMode.AVG}) {
|
||||
final NumericDoubleValues selected = mode.select(values, missingValue, rootDocs, new BitDocIdSet(innerDocs), maxDoc);
|
||||
final NumericDoubleValues selected = mode.select(values, missingValue, rootDocs, new BitSetIterator(innerDocs, 0L), maxDoc);
|
||||
int prevRoot = -1;
|
||||
for (int root = rootDocs.nextSetBit(0); root != -1; root = root + 1 < maxDoc ? rootDocs.nextSetBit(root + 1) : -1) {
|
||||
final double actual = selected.get(root);
|
||||
|
@ -460,7 +461,7 @@ public class MultiValueModeTests extends ESTestCase {
|
|||
private void verify(SortedBinaryDocValues values, int maxDoc, FixedBitSet rootDocs, FixedBitSet innerDocs) throws IOException {
|
||||
for (BytesRef missingValue : new BytesRef[] { new BytesRef(), new BytesRef(RandomStrings.randomAsciiOfLength(getRandom(), 8)) }) {
|
||||
for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) {
|
||||
final BinaryDocValues selected = mode.select(values, missingValue, rootDocs, new BitDocIdSet(innerDocs), maxDoc);
|
||||
final BinaryDocValues selected = mode.select(values, missingValue, rootDocs, new BitSetIterator(innerDocs, 0L), maxDoc);
|
||||
int prevRoot = -1;
|
||||
for (int root = rootDocs.nextSetBit(0); root != -1; root = root + 1 < maxDoc ? rootDocs.nextSetBit(root + 1) : -1) {
|
||||
final BytesRef actual = selected.get(root);
|
||||
|
@ -600,7 +601,7 @@ public class MultiValueModeTests extends ESTestCase {
|
|||
|
||||
private void verify(RandomAccessOrds values, int maxDoc, FixedBitSet rootDocs, FixedBitSet innerDocs) throws IOException {
|
||||
for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) {
|
||||
final SortedDocValues selected = mode.select(values, rootDocs, new BitDocIdSet(innerDocs));
|
||||
final SortedDocValues selected = mode.select(values, rootDocs, new BitSetIterator(innerDocs, 0L));
|
||||
int prevRoot = -1;
|
||||
for (int root = rootDocs.nextSetBit(0); root != -1; root = root + 1 < maxDoc ? rootDocs.nextSetBit(root + 1) : -1) {
|
||||
final int actual = selected.getOrd(root);
|
||||
|
@ -649,7 +650,6 @@ public class MultiValueModeTests extends ESTestCase {
|
|||
};
|
||||
final SortedNumericDoubleValues singletonValues = FieldData.singleton(singleValues, docsWithValue);
|
||||
final MultiValueMode.UnsortedNumericDoubleValues multiValues = new MultiValueMode.UnsortedNumericDoubleValues() {
|
||||
int doc;
|
||||
|
||||
@Override
|
||||
public int count() {
|
||||
|
|
|
@ -29,11 +29,11 @@ import org.apache.lucene.index.RandomIndexWriter;
|
|||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TotalHitCountCollector;
|
||||
import org.apache.lucene.search.Weight;
|
||||
import org.apache.lucene.search.join.BitSetProducer;
|
||||
import org.apache.lucene.search.join.QueryBitSetProducer;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
@ -80,10 +80,11 @@ public class NestedChildrenFilterTests extends ESTestCase {
|
|||
IndexSearcher searcher = new IndexSearcher(reader);
|
||||
FetchSubPhase.HitContext hitContext = new FetchSubPhase.HitContext();
|
||||
BitSetProducer parentFilter = new QueryBitSetProducer(new TermQuery(new Term("type", "parent")));
|
||||
Filter childFilter = new QueryWrapperFilter(new TermQuery(new Term("type", "child")));
|
||||
Query childFilter = new TermQuery(new Term("type", "child"));
|
||||
int checkedParents = 0;
|
||||
final Weight parentsWeight = searcher.createNormalizedWeight(new TermQuery(new Term("type", "parent")), false);
|
||||
for (LeafReaderContext leaf : reader.leaves()) {
|
||||
DocIdSetIterator parents = new QueryWrapperFilter(new TermQuery(new Term("type", "parent"))).getDocIdSet(leaf, null).iterator();
|
||||
DocIdSetIterator parents = parentsWeight.scorer(leaf);
|
||||
for (int parentDoc = parents.nextDoc(); parentDoc != DocIdSetIterator.NO_MORE_DOCS ; parentDoc = parents.nextDoc()) {
|
||||
int expectedChildDocs = leaf.reader().document(parentDoc).getField("num_child_docs").numericValue().intValue();
|
||||
hitContext.reset(null, leaf, parentDoc, searcher);
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.test;
|
|||
import com.carrotsearch.hppc.ObjectObjectAssociativeContainer;
|
||||
|
||||
import org.apache.lucene.search.Collector;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.util.Counter;
|
||||
|
@ -133,7 +132,7 @@ public class TestSearchContext extends SearchContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Filter searchFilter(String[] types) {
|
||||
public Query searchFilter(String[] types) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -413,7 +412,7 @@ public class TestSearchContext extends SearchContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Filter aliasFilter() {
|
||||
public Query aliasFilter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,13 @@ org.apache.lucene.index.DocsEnum
|
|||
org.apache.lucene.index.DocsAndPositionsEnum
|
||||
org.apache.lucene.queries.TermFilter
|
||||
org.apache.lucene.queries.TermsFilter
|
||||
org.apache.lucene.search.Filter
|
||||
org.apache.lucene.search.FilteredQuery
|
||||
org.apache.lucene.search.TermRangeFilter
|
||||
org.apache.lucene.search.NumericRangeFilter
|
||||
org.apache.lucene.search.PrefixFilter
|
||||
org.apache.lucene.search.QueryWrapperFilter
|
||||
org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter
|
||||
|
||||
java.nio.file.Paths @ Use org.elasticsearch.common.io.PathUtils.get() instead.
|
||||
java.nio.file.FileSystems#getDefault() @ use org.elasticsearch.common.io.PathUtils.getDefaultFileSystem() instead.
|
||||
|
|
Loading…
Reference in New Issue