Module org.elasticsearch.server
Package org.elasticsearch.index.query
Class FilteredSearchExecutionContext
java.lang.Object
org.elasticsearch.index.query.QueryRewriteContext
org.elasticsearch.index.query.SearchExecutionContext
org.elasticsearch.index.query.FilteredSearchExecutionContext
This is NOT a simple clone of the SearchExecutionContext.
While it does "clone-esque" things, it delegates everything it can to the passed search execution context.
Do NOT use this if you mean to clone the context as you are planning to make modifications
-
Field Summary
Fields inherited from class org.elasticsearch.index.query.QueryRewriteContext
allowedFields, allowExpensiveQueries, allowUnmappedFields, client, fullyQualifiedIndex, indexNameMatcher, indexSettings, mapperService, mappingLookup, mapUnmappedFieldAsString, nowInMillis, runtimeMappings, scriptService, valuesSourceRegistry, writeableRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNamedQuery(String name, org.apache.lucene.search.Query query) booleanorg.apache.lucene.search.join.BitSetProducerbitsetFilter(org.apache.lucene.search.Query filter) Given a type (eg.<FactoryType>
FactoryTypecompile(Script script, ScriptContext<FactoryType> context) Compile script using script servicebooleancontainsBrokenAnalysis(String field) Does the index analyzer for this field have token filters that may produce backwards offsets in term vectorsReturns an instance ofCoordinatorRewriteContextif available or null otherwiseReturns an instance ofDataRewriteContextif available or null otherwisevoidMarks this context as not cacheable.voidexecuteAsyncActions(ActionListener<Void> listener) Executes all registered async actions and notifies the listener once it's done.booleanfieldExistsInIndex(String fieldname) Is this field present in the underlying lucene index for the current shard?protected MappedFieldTypeorg.apache.lucene.search.similarities.SimilarityThe default similarity configured in the index settings.getFieldType(String name) Returns theMappedFieldTypefor the provided field name.<IFD extends IndexFieldData<?>>
IFDgetForField(MappedFieldType fieldType, MappedFieldType.FielddataOperation fielddataOperation) Returns the fully qualified index including a remote cluster alias if applicable, and the index uuidorg.apache.lucene.analysis.AnalyzergetIndexAnalyzer(Function<String, NamedAnalyzer> unindexedFieldAnalyzer) Return the index-time analyzer for the current indexorg.apache.lucene.index.IndexReaderReturn the currentIndexReader, ornullif no index reader is available, for instance if this rewrite context is used to index queries (percolation).Returns the index settings for this context.getMatchingFieldNames(String pattern) Returns the names of all mapped fields that match a given pattern All names returned by this method are guaranteed to resolve to a MappedFieldType if passed toQueryRewriteContext.getFieldType(String)The registry used to build newXContentParsers.org.apache.lucene.search.similarities.SimilarityThe similarity to use in searches, which takes into account per-field configuration.intReturns the shard ID this context was created for.intReturns the shard request ordinal that is used by the main search request to reference this shard.booleanReturnstrueif there are any registered async actions.booleanindex()booleanindexMatches(String pattern) Given an index pattern, checks whether it matches against the current shard.booleanindexSortedOnField(String field) booleanisFieldMapped(String name) Returns true if the field identified by the provided name is mapped, false otherwisebooleanisMetadataField(String field) booleanisMultiField(String field) booleanWill there be_source.booleanDoes the source need to be rebuilt on the fly?lookup()Get the lookup to use during the search.Cache key for current mapping.newSourceLoader(SourceFilter filter, boolean forceSyntheticSource) Build something to load source_source.longReturns the time in milliseconds that is shared across all resources involved.parseDocument(SourceToParse source) Parse a document with current mapping.booleanbooleanbooleanvoidregisterAsyncAction(BiConsumer<Client, ActionListener<?>> asyncAction) Registers an async action that must be executed before the next rewrite round in order to make progress.booleanReturns true if Elasticsearch queries with _name must be rewritten to Lucene NamedQueryorg.apache.lucene.search.IndexSearchersearcher()Return the currentIndexSearcher, ornullif no index reader is available, which happens if this rewrite context is used to index queries (percolation).voidsetAllowedFields(Predicate<String> allowedFields) voidsetAllowUnmappedFields(boolean allowUnmappedFields) voidsetLookupProviders(SourceProvider sourceProvider, Function<org.apache.lucene.index.LeafReaderContext, LeafFieldLookupProvider> fieldLookupProvider) Replace the standard source provider and field lookup provider on the SearchLookup Note that this will replace the current SearchLookup with a new one, but will not update the source provider on previously build lookups.voidsetMapUnmappedFieldAsString(boolean mapUnmappedFieldAsString) voidInstructs to rewrite Elasticsearch queries with _name to Lucene NamedQuerysourcePath(String fullName) toQuery(QueryBuilder queryBuilder) Methods inherited from class org.elasticsearch.index.query.SearchExecutionContext
convertToSearchExecutionContext, createSourceProvider, dimensionFields, failIfFrozen, freezeContext, getAliasFilter, hasNamedQueries, isCacheable, parentPath, requestSize, setAliasFilterMethods inherited from class org.elasticsearch.index.query.QueryRewriteContext
convertToInnerHitsRewriteContext, getAllFields, getMappingLookup, getPointInTimeBuilder, getQueryRewriteInterceptor, getResolvedIndices, getTierPreference, isExplain, setQueryRewriteInterceptor
-
Constructor Details
-
FilteredSearchExecutionContext
-
-
Method Details
-
getSearchSimilarity
public org.apache.lucene.search.similarities.Similarity getSearchSimilarity()Description copied from class:SearchExecutionContextThe similarity to use in searches, which takes into account per-field configuration.- Overrides:
getSearchSimilarityin classSearchExecutionContext
-
getDefaultSimilarity
public org.apache.lucene.search.similarities.Similarity getDefaultSimilarity()Description copied from class:SearchExecutionContextThe default similarity configured in the index settings.- Overrides:
getDefaultSimilarityin classSearchExecutionContext
-
defaultFields
- Overrides:
defaultFieldsin classSearchExecutionContext
-
queryStringLenient
public boolean queryStringLenient()- Overrides:
queryStringLenientin classSearchExecutionContext
-
queryStringAnalyzeWildcard
public boolean queryStringAnalyzeWildcard()- Overrides:
queryStringAnalyzeWildcardin classSearchExecutionContext
-
queryStringAllowLeadingWildcard
public boolean queryStringAllowLeadingWildcard()- Overrides:
queryStringAllowLeadingWildcardin classSearchExecutionContext
-
bitsetFilter
public org.apache.lucene.search.join.BitSetProducer bitsetFilter(org.apache.lucene.search.Query filter) - Overrides:
bitsetFilterin classSearchExecutionContext
-
getForField
public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType, MappedFieldType.FielddataOperation fielddataOperation) - Overrides:
getForFieldin classSearchExecutionContext
-
addNamedQuery
- Overrides:
addNamedQueryin classSearchExecutionContext
-
copyNamedQueries
- Overrides:
copyNamedQueriesin classSearchExecutionContext
-
parseDocument
Description copied from class:SearchExecutionContextParse a document with current mapping.- Overrides:
parseDocumentin classSearchExecutionContext- Throws:
DocumentParsingException
-
nestedLookup
- Overrides:
nestedLookupin classSearchExecutionContext
-
hasMappings
public boolean hasMappings()- Overrides:
hasMappingsin classSearchExecutionContext
-
isFieldMapped
Description copied from class:SearchExecutionContextReturns true if the field identified by the provided name is mapped, false otherwise- Overrides:
isFieldMappedin classSearchExecutionContext
-
isMetadataField
- Overrides:
isMetadataFieldin classSearchExecutionContext
-
isMultiField
- Overrides:
isMultiFieldin classSearchExecutionContext
-
sourcePath
- Overrides:
sourcePathin classSearchExecutionContext
-
isSourceEnabled
public boolean isSourceEnabled()Description copied from class:SearchExecutionContextWill there be_source.- Overrides:
isSourceEnabledin classSearchExecutionContext
-
isSourceSynthetic
public boolean isSourceSynthetic()Description copied from class:SearchExecutionContextDoes the source need to be rebuilt on the fly?- Overrides:
isSourceSyntheticin classSearchExecutionContext
-
newSourceLoader
Description copied from class:SearchExecutionContextBuild something to load source_source.- Overrides:
newSourceLoaderin classSearchExecutionContext
-
buildAnonymousFieldType
Description copied from class:SearchExecutionContextGiven a type (eg. long, string, ...), returns an anonymous field type that can be used for search operations. Generally used to handle unmapped fields in the context of sorting.- Overrides:
buildAnonymousFieldTypein classSearchExecutionContext
-
getIndexAnalyzer
public org.apache.lucene.analysis.Analyzer getIndexAnalyzer(Function<String, NamedAnalyzer> unindexedFieldAnalyzer) Description copied from class:SearchExecutionContextReturn the index-time analyzer for the current index- Overrides:
getIndexAnalyzerin classSearchExecutionContext- Parameters:
unindexedFieldAnalyzer- a function that builds an analyzer for unindexed fields
-
setAllowedFields
- Overrides:
setAllowedFieldsin classSearchExecutionContext
-
containsBrokenAnalysis
Description copied from class:SearchExecutionContextDoes the index analyzer for this field have token filters that may produce backwards offsets in term vectors- Overrides:
containsBrokenAnalysisin classSearchExecutionContext
-
lookup
Description copied from class:SearchExecutionContextGet the lookup to use during the search.- Overrides:
lookupin classSearchExecutionContext
-
setLookupProviders
public void setLookupProviders(SourceProvider sourceProvider, Function<org.apache.lucene.index.LeafReaderContext, LeafFieldLookupProvider> fieldLookupProvider) Description copied from class:SearchExecutionContextReplace the standard source provider and field lookup provider on the SearchLookup Note that this will replace the current SearchLookup with a new one, but will not update the source provider on previously build lookups. This method should only be called before IndexReader access by the current context- Overrides:
setLookupProvidersin classSearchExecutionContext
-
nestedScope
- Overrides:
nestedScopein classSearchExecutionContext
-
indexVersionCreated
- Overrides:
indexVersionCreatedin classSearchExecutionContext
-
indexSortedOnField
- Overrides:
indexSortedOnFieldin classSearchExecutionContext
-
toQuery
- Overrides:
toQueryin classSearchExecutionContext
-
index
- Overrides:
indexin classSearchExecutionContext
-
compile
Description copied from class:SearchExecutionContextCompile script using script service- Overrides:
compilein classSearchExecutionContext
-
disableCache
public void disableCache()Description copied from class:SearchExecutionContextMarks this context as not cacheable. This method fails ifSearchExecutionContext.freezeContext()is called before on this context.- Overrides:
disableCachein classSearchExecutionContext
-
registerAsyncAction
Description copied from class:QueryRewriteContextRegisters an async action that must be executed before the next rewrite round in order to make progress. This should be used if a rewriteable needs to fetch some external resources in order to be executed ie. a document from an index.- Overrides:
registerAsyncActionin classSearchExecutionContext
-
executeAsyncActions
Description copied from class:QueryRewriteContextExecutes all registered async actions and notifies the listener once it's done. The value that is passed to the listener is alwaysnull. The list of registered actions is cleared once this method returns.- Overrides:
executeAsyncActionsin classSearchExecutionContext
-
getShardId
public int getShardId()Description copied from class:SearchExecutionContextReturns the shard ID this context was created for.- Overrides:
getShardIdin classSearchExecutionContext
-
getShardRequestIndex
public int getShardRequestIndex()Description copied from class:SearchExecutionContextReturns the shard request ordinal that is used by the main search request to reference this shard.- Overrides:
getShardRequestIndexin classSearchExecutionContext
-
nowInMillis
public long nowInMillis()Description copied from class:SearchExecutionContextReturns the time in milliseconds that is shared across all resources involved. Even across shards and nodes.- Overrides:
nowInMillisin classSearchExecutionContext
-
getClient
- Overrides:
getClientin classSearchExecutionContext
-
getIndexReader
public org.apache.lucene.index.IndexReader getIndexReader()Description copied from class:SearchExecutionContextReturn the currentIndexReader, ornullif no index reader is available, for instance if this rewrite context is used to index queries (percolation).- Overrides:
getIndexReaderin classSearchExecutionContext
-
searcher
public org.apache.lucene.search.IndexSearcher searcher()Description copied from class:SearchExecutionContextReturn the currentIndexSearcher, ornullif no index reader is available, which happens if this rewrite context is used to index queries (percolation).- Overrides:
searcherin classSearchExecutionContext
-
fieldExistsInIndex
Description copied from class:SearchExecutionContextIs this field present in the underlying lucene index for the current shard?- Overrides:
fieldExistsInIndexin classSearchExecutionContext
-
mappingCacheKey
Description copied from class:SearchExecutionContextCache key for current mapping.- Overrides:
mappingCacheKeyin classSearchExecutionContext
-
getNestedDocuments
- Overrides:
getNestedDocumentsin classSearchExecutionContext
-
getParserConfig
Description copied from class:QueryRewriteContextThe registry used to build newXContentParsers. Contains registered named parsers needed to parse the query. Used by WrapperQueryBuilder- Overrides:
getParserConfigin classQueryRewriteContext
-
convertToCoordinatorRewriteContext
Description copied from class:QueryRewriteContextReturns an instance ofCoordinatorRewriteContextif available or null otherwise- Overrides:
convertToCoordinatorRewriteContextin classQueryRewriteContext
-
convertToIndexMetadataContext
- Overrides:
convertToIndexMetadataContextin classQueryRewriteContext- Returns:
- an
QueryRewriteContextinstance that is aware of the mapping and other index metadata ornullotherwise.
-
convertToDataRewriteContext
Description copied from class:QueryRewriteContextReturns an instance ofDataRewriteContextif available or null otherwise- Overrides:
convertToDataRewriteContextin classQueryRewriteContext
-
getFieldType
Description copied from class:QueryRewriteContextReturns theMappedFieldTypefor the provided field name. If the field is not mapped, the behaviour depends on the index.query.parse.allow_unmapped_fields setting, which defaults to true. In case unmapped fields are allowed, null is returned when the field is not mapped. In case unmapped fields are not allowed, either an exception is thrown or the field is automatically mapped as a text field.- Overrides:
getFieldTypein classQueryRewriteContext- See Also:
-
fieldType
- Overrides:
fieldTypein classQueryRewriteContext
-
getIndexAnalyzers
- Overrides:
getIndexAnalyzersin classQueryRewriteContext
-
setAllowUnmappedFields
public void setAllowUnmappedFields(boolean allowUnmappedFields) - Overrides:
setAllowUnmappedFieldsin classQueryRewriteContext
-
setMapUnmappedFieldAsString
public void setMapUnmappedFieldAsString(boolean mapUnmappedFieldAsString) - Overrides:
setMapUnmappedFieldAsStringin classQueryRewriteContext
-
getWriteableRegistry
- Overrides:
getWriteableRegistryin classQueryRewriteContext
-
getValuesSourceRegistry
- Overrides:
getValuesSourceRegistryin classQueryRewriteContext
-
allowExpensiveQueries
public boolean allowExpensiveQueries()- Overrides:
allowExpensiveQueriesin classQueryRewriteContext
-
hasAsyncActions
public boolean hasAsyncActions()Description copied from class:QueryRewriteContextReturnstrueif there are any registered async actions.- Overrides:
hasAsyncActionsin classQueryRewriteContext
-
getFullyQualifiedIndex
Description copied from class:QueryRewriteContextReturns the fully qualified index including a remote cluster alias if applicable, and the index uuid- Overrides:
getFullyQualifiedIndexin classQueryRewriteContext
-
getIndexSettings
Description copied from class:QueryRewriteContextReturns the index settings for this context. This might return null if the context has not index scope.- Overrides:
getIndexSettingsin classQueryRewriteContext
-
indexMatches
Description copied from class:QueryRewriteContextGiven an index pattern, checks whether it matches against the current shard. The pattern may represent a fully qualified index name if the search targets remote shards.- Overrides:
indexMatchesin classQueryRewriteContext
-
getMatchingFieldNames
Description copied from class:QueryRewriteContextReturns the names of all mapped fields that match a given pattern All names returned by this method are guaranteed to resolve to a MappedFieldType if passed toQueryRewriteContext.getFieldType(String)- Overrides:
getMatchingFieldNamesin classQueryRewriteContext- Parameters:
pattern- the field name pattern
-
setRewriteToNamedQueries
public void setRewriteToNamedQueries()Description copied from class:SearchExecutionContextInstructs to rewrite Elasticsearch queries with _name to Lucene NamedQuery- Overrides:
setRewriteToNamedQueriesin classSearchExecutionContext
-
rewriteToNamedQuery
public boolean rewriteToNamedQuery()Description copied from class:SearchExecutionContextReturns true if Elasticsearch queries with _name must be rewritten to Lucene NamedQuery- Overrides:
rewriteToNamedQueryin classSearchExecutionContext- Returns:
-