java.lang.Object
org.elasticsearch.search.lookup.SearchLookup
- All Implemented Interfaces:
SourceProvider
Provides a way to look up per-document values from docvalues, stored fields or _source
-
Constructor Summary
ConstructorsConstructorDescriptionSearchLookup(Function<String, MappedFieldType> fieldTypeLookup, Function<String, Boolean> onlyMappedAsRuntimeField, TriFunction<MappedFieldType, Supplier<SearchLookup>, MappedFieldType.FielddataOperation, IndexFieldData<?>> fieldDataLookup, SourceProvider sourceProvider, Function<org.apache.lucene.index.LeafReaderContext, LeafFieldLookupProvider> fieldLookupProvider) Create a new SearchLookup, using the default stored fields providerSearchLookup(Function<String, MappedFieldType> fieldTypeLookup, TriFunction<MappedFieldType, Supplier<SearchLookup>, MappedFieldType.FielddataOperation, IndexFieldData<?>> fieldDataLookup, SourceProvider sourceProvider) Create a new SearchLookup, using the default stored fields provider -
Method Summary
Modifier and TypeMethodDescriptionfinal SearchLookupCreates a copy of the currentSearchLookupthat looks fields up in the same way, but also tracks field references in order to detect cycles and prevent resolving fields that depend on more thanMAX_FIELD_CHAIN_DEPTHother fields.getForField(MappedFieldType fieldType, MappedFieldType.FielddataOperation options) getLeafSearchLookup(org.apache.lucene.index.LeafReaderContext context) getSource(org.apache.lucene.index.LeafReaderContext ctx, int doc) Get the Source for the given doc within the given contextbooleanonlyMappedAsRuntimeField(String fieldName) optimizedSourceProvider(SourceFilter sourceFilter) Optionally returns a newSourceProviderthat is more optimized to load source with the provided source filter in mind.
-
Constructor Details
-
SearchLookup
public SearchLookup(Function<String, MappedFieldType> fieldTypeLookup, TriFunction<MappedFieldType, Supplier<SearchLookup>, MappedFieldType.FielddataOperation, IndexFieldData<?>> fieldDataLookup, SourceProvider sourceProvider) Create a new SearchLookup, using the default stored fields provider- Parameters:
fieldTypeLookup- defines how to look up field typesfieldDataLookup- defines how to look up field datasourceProvider- defines how to look up the source
-
SearchLookup
public SearchLookup(Function<String, MappedFieldType> fieldTypeLookup, Function<String, Boolean> onlyMappedAsRuntimeField, TriFunction<MappedFieldType, Supplier<SearchLookup>, MappedFieldType.FielddataOperation, IndexFieldData<?>> fieldDataLookup, SourceProvider sourceProvider, Function<org.apache.lucene.index.LeafReaderContext, LeafFieldLookupProvider> fieldLookupProvider) Create a new SearchLookup, using the default stored fields provider- Parameters:
fieldTypeLookup- defines how to look up field typesfieldDataLookup- defines how to look up field datasourceProvider- defines how to look up the sourcefieldLookupProvider- defines how to look up stored fields
-
-
Method Details
-
forkAndTrackFieldReferences
Creates a copy of the currentSearchLookupthat looks fields up in the same way, but also tracks field references in order to detect cycles and prevent resolving fields that depend on more thanMAX_FIELD_CHAIN_DEPTHother fields.- Parameters:
field- the field being referred to, for which fielddata needs to be loaded- Returns:
- the new lookup
- Throws:
IllegalArgumentException- if a cycle is detected in the fields required to build doc values, or if the field being resolved depends on more thanMAX_FIELD_CHAIN_DEPTH
-
getLeafSearchLookup
-
fieldType
-
onlyMappedAsRuntimeField
- Returns:
- whether a field is only mapped as runtime field. A runtime and normal field can share the same name.
-
getForField
public IndexFieldData<?> getForField(MappedFieldType fieldType, MappedFieldType.FielddataOperation options) -
getSource
Description copied from interface:SourceProviderGet the Source for the given doc within the given context- Specified by:
getSourcein interfaceSourceProvider- Throws:
IOException
-
optimizedSourceProvider
Description copied from interface:SourceProviderOptionally returns a newSourceProviderthat is more optimized to load source with the provided source filter in mind.Currently this is only the case if source mode is synthetic, and only a subset of fields is requested, then only loading source for requested fields is much more efficient.
- Specified by:
optimizedSourceProviderin interfaceSourceProvider- Parameters:
sourceFilter- The part of the source the caller is actually interested in.- Returns:
- a new instance if source can be loaded in a more optimal way, otherwise returns this instance.
-