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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addNamedQuery
(String name, org.apache.lucene.search.Query query) boolean
org.apache.lucene.search.join.BitSetProducer
bitsetFilter
(org.apache.lucene.search.Query filter) Given a type (eg.<FactoryType>
FactoryTypecompile
(Script script, ScriptContext<FactoryType> context) Compile script using script serviceboolean
containsBrokenAnalysis
(String field) Does the index analyzer for this field have token filters that may produce backwards offsets in term vectorsReturns an instance ofCoordinatorRewriteContext
if available or null otherwiseReturns an instance ofDataRewriteContext
if available or null otherwisevoid
Marks this context as not cacheable.void
executeAsyncActions
(ActionListener listener) Executes all registered async actions and notifies the listener once it's done.boolean
fieldExistsInIndex
(String fieldname) Is this field present in the underlying lucene index for the current shard?protected MappedFieldType
org.apache.lucene.search.similarities.Similarity
The default similarity configured in the index settings.getFieldType
(String name) Returns theMappedFieldType
for 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.Analyzer
getIndexAnalyzer
(Function<String, NamedAnalyzer> unindexedFieldAnalyzer) Return the index-time analyzer for the current indexorg.apache.lucene.index.IndexReader
Return the currentIndexReader
, ornull
if 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 newXContentParser
s.org.apache.lucene.search.similarities.Similarity
The similarity to use in searches, which takes into account per-field configuration.int
Returns the shard ID this context was created for.int
Returns the shard request ordinal that is used by the main search request to reference this shard.boolean
Returnstrue
if there are any registered async actions.boolean
index()
boolean
indexMatches
(String pattern) Given an index pattern, checks whether it matches against the current shard.boolean
indexSortedOnField
(String field) boolean
isFieldMapped
(String name) Returns true if the field identified by the provided name is mapped, false otherwiseboolean
isMetadataField
(String field) boolean
isMultiField
(String field) boolean
Will there be_source
.boolean
Does the source need to be rebuilt on the fly?lookup()
Get the lookup to use during the search.Cache key for current mapping.newSourceLoader
(boolean forceSyntheticSource) Build something to load source_source
.long
Returns the time in milliseconds that is shared across all resources involved.parseDocument
(SourceToParse source) Parse a document with current mapping.boolean
boolean
boolean
void
registerAsyncAction
(BiConsumer<Client, ActionListener<?>> asyncAction) Registers an async action that must be executed before the next rewrite round in order to make progress.boolean
Returns true if Elasticsearch queries with _name must be rewritten to Lucene NamedQueryorg.apache.lucene.search.IndexSearcher
searcher()
Return the currentIndexSearcher
, ornull
if no index reader is available, which happens if this rewrite context is used to index queries (percolation).void
setAllowedFields
(Predicate<String> allowedFields) void
setAllowUnmappedFields
(boolean allowUnmappedFields) void
setLookupProviders
(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.void
setMapUnmappedFieldAsString
(boolean mapUnmappedFieldAsString) void
Instructs to rewrite Elasticsearch queries with _name to Lucene NamedQuerysourcePath
(String fullName) toQuery
(QueryBuilder queryBuilder) Methods inherited from class org.elasticsearch.index.query.SearchExecutionContext
convertToSearchExecutionContext, dimensionFields, failIfFrozen, freezeContext, getAliasFilter, hasNamedQueries, isCacheable, parentPath, requestSize, setAliasFilter
Methods inherited from class org.elasticsearch.index.query.QueryRewriteContext
convertToInnerHitsRewriteContext, getAllFields, getMappingLookup
-
Constructor Details
-
FilteredSearchExecutionContext
-
-
Method Details
-
getSearchSimilarity
public org.apache.lucene.search.similarities.Similarity getSearchSimilarity()Description copied from class:SearchExecutionContext
The similarity to use in searches, which takes into account per-field configuration.- Overrides:
getSearchSimilarity
in classSearchExecutionContext
-
getDefaultSimilarity
public org.apache.lucene.search.similarities.Similarity getDefaultSimilarity()Description copied from class:SearchExecutionContext
The default similarity configured in the index settings.- Overrides:
getDefaultSimilarity
in classSearchExecutionContext
-
defaultFields
- Overrides:
defaultFields
in classSearchExecutionContext
-
queryStringLenient
public boolean queryStringLenient()- Overrides:
queryStringLenient
in classSearchExecutionContext
-
queryStringAnalyzeWildcard
public boolean queryStringAnalyzeWildcard()- Overrides:
queryStringAnalyzeWildcard
in classSearchExecutionContext
-
queryStringAllowLeadingWildcard
public boolean queryStringAllowLeadingWildcard()- Overrides:
queryStringAllowLeadingWildcard
in classSearchExecutionContext
-
bitsetFilter
public org.apache.lucene.search.join.BitSetProducer bitsetFilter(org.apache.lucene.search.Query filter) - Overrides:
bitsetFilter
in classSearchExecutionContext
-
getForField
public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType, MappedFieldType.FielddataOperation fielddataOperation) - Overrides:
getForField
in classSearchExecutionContext
-
addNamedQuery
- Overrides:
addNamedQuery
in classSearchExecutionContext
-
copyNamedQueries
- Overrides:
copyNamedQueries
in classSearchExecutionContext
-
parseDocument
Description copied from class:SearchExecutionContext
Parse a document with current mapping.- Overrides:
parseDocument
in classSearchExecutionContext
- Throws:
DocumentParsingException
-
nestedLookup
- Overrides:
nestedLookup
in classSearchExecutionContext
-
hasMappings
public boolean hasMappings()- Overrides:
hasMappings
in classSearchExecutionContext
-
isFieldMapped
Description copied from class:SearchExecutionContext
Returns true if the field identified by the provided name is mapped, false otherwise- Overrides:
isFieldMapped
in classSearchExecutionContext
-
isMetadataField
- Overrides:
isMetadataField
in classSearchExecutionContext
-
isMultiField
- Overrides:
isMultiField
in classSearchExecutionContext
-
sourcePath
- Overrides:
sourcePath
in classSearchExecutionContext
-
isSourceEnabled
public boolean isSourceEnabled()Description copied from class:SearchExecutionContext
Will there be_source
.- Overrides:
isSourceEnabled
in classSearchExecutionContext
-
isSourceSynthetic
public boolean isSourceSynthetic()Description copied from class:SearchExecutionContext
Does the source need to be rebuilt on the fly?- Overrides:
isSourceSynthetic
in classSearchExecutionContext
-
newSourceLoader
Description copied from class:SearchExecutionContext
Build something to load source_source
.- Overrides:
newSourceLoader
in classSearchExecutionContext
-
buildAnonymousFieldType
Description copied from class:SearchExecutionContext
Given 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:
buildAnonymousFieldType
in classSearchExecutionContext
-
getIndexAnalyzer
public org.apache.lucene.analysis.Analyzer getIndexAnalyzer(Function<String, NamedAnalyzer> unindexedFieldAnalyzer) Description copied from class:SearchExecutionContext
Return the index-time analyzer for the current index- Overrides:
getIndexAnalyzer
in classSearchExecutionContext
- Parameters:
unindexedFieldAnalyzer
- a function that builds an analyzer for unindexed fields
-
setAllowedFields
- Overrides:
setAllowedFields
in classSearchExecutionContext
-
containsBrokenAnalysis
Description copied from class:SearchExecutionContext
Does the index analyzer for this field have token filters that may produce backwards offsets in term vectors- Overrides:
containsBrokenAnalysis
in classSearchExecutionContext
-
lookup
Description copied from class:SearchExecutionContext
Get the lookup to use during the search.- Overrides:
lookup
in classSearchExecutionContext
-
setLookupProviders
public void setLookupProviders(SourceProvider sourceProvider, Function<org.apache.lucene.index.LeafReaderContext, LeafFieldLookupProvider> fieldLookupProvider) Description copied from class:SearchExecutionContext
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. This method should only be called before IndexReader access by the current context- Overrides:
setLookupProviders
in classSearchExecutionContext
-
nestedScope
- Overrides:
nestedScope
in classSearchExecutionContext
-
indexVersionCreated
- Overrides:
indexVersionCreated
in classSearchExecutionContext
-
indexSortedOnField
- Overrides:
indexSortedOnField
in classSearchExecutionContext
-
toQuery
- Overrides:
toQuery
in classSearchExecutionContext
-
index
- Overrides:
index
in classSearchExecutionContext
-
compile
Description copied from class:SearchExecutionContext
Compile script using script service- Overrides:
compile
in classSearchExecutionContext
-
disableCache
public void disableCache()Description copied from class:SearchExecutionContext
Marks this context as not cacheable. This method fails ifSearchExecutionContext.freezeContext()
is called before on this context.- Overrides:
disableCache
in classSearchExecutionContext
-
registerAsyncAction
Description copied from class:QueryRewriteContext
Registers 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:
registerAsyncAction
in classSearchExecutionContext
-
executeAsyncActions
Description copied from class:QueryRewriteContext
Executes 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:
executeAsyncActions
in classSearchExecutionContext
-
getShardId
public int getShardId()Description copied from class:SearchExecutionContext
Returns the shard ID this context was created for.- Overrides:
getShardId
in classSearchExecutionContext
-
getShardRequestIndex
public int getShardRequestIndex()Description copied from class:SearchExecutionContext
Returns the shard request ordinal that is used by the main search request to reference this shard.- Overrides:
getShardRequestIndex
in classSearchExecutionContext
-
nowInMillis
public long nowInMillis()Description copied from class:SearchExecutionContext
Returns the time in milliseconds that is shared across all resources involved. Even across shards and nodes.- Overrides:
nowInMillis
in classSearchExecutionContext
-
getClient
- Overrides:
getClient
in classSearchExecutionContext
-
getIndexReader
public org.apache.lucene.index.IndexReader getIndexReader()Description copied from class:SearchExecutionContext
Return the currentIndexReader
, ornull
if no index reader is available, for instance if this rewrite context is used to index queries (percolation).- Overrides:
getIndexReader
in classSearchExecutionContext
-
searcher
public org.apache.lucene.search.IndexSearcher searcher()Description copied from class:SearchExecutionContext
Return the currentIndexSearcher
, ornull
if no index reader is available, which happens if this rewrite context is used to index queries (percolation).- Overrides:
searcher
in classSearchExecutionContext
-
fieldExistsInIndex
Description copied from class:SearchExecutionContext
Is this field present in the underlying lucene index for the current shard?- Overrides:
fieldExistsInIndex
in classSearchExecutionContext
-
mappingCacheKey
Description copied from class:SearchExecutionContext
Cache key for current mapping.- Overrides:
mappingCacheKey
in classSearchExecutionContext
-
getNestedDocuments
- Overrides:
getNestedDocuments
in classSearchExecutionContext
-
getParserConfig
Description copied from class:QueryRewriteContext
The registry used to build newXContentParser
s. Contains registered named parsers needed to parse the query. Used by WrapperQueryBuilder- Overrides:
getParserConfig
in classQueryRewriteContext
-
convertToCoordinatorRewriteContext
Description copied from class:QueryRewriteContext
Returns an instance ofCoordinatorRewriteContext
if available or null otherwise- Overrides:
convertToCoordinatorRewriteContext
in classQueryRewriteContext
-
convertToIndexMetadataContext
- Overrides:
convertToIndexMetadataContext
in classQueryRewriteContext
- Returns:
- an
QueryRewriteContext
instance that is aware of the mapping and other index metadata ornull
otherwise.
-
convertToDataRewriteContext
Description copied from class:QueryRewriteContext
Returns an instance ofDataRewriteContext
if available or null otherwise- Overrides:
convertToDataRewriteContext
in classQueryRewriteContext
-
getFieldType
Description copied from class:QueryRewriteContext
Returns theMappedFieldType
for 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. -
fieldType
- Overrides:
fieldType
in classQueryRewriteContext
-
getIndexAnalyzers
- Overrides:
getIndexAnalyzers
in classQueryRewriteContext
-
setAllowUnmappedFields
public void setAllowUnmappedFields(boolean allowUnmappedFields) - Overrides:
setAllowUnmappedFields
in classQueryRewriteContext
-
setMapUnmappedFieldAsString
public void setMapUnmappedFieldAsString(boolean mapUnmappedFieldAsString) - Overrides:
setMapUnmappedFieldAsString
in classQueryRewriteContext
-
getWriteableRegistry
- Overrides:
getWriteableRegistry
in classQueryRewriteContext
-
getValuesSourceRegistry
- Overrides:
getValuesSourceRegistry
in classQueryRewriteContext
-
allowExpensiveQueries
public boolean allowExpensiveQueries()- Overrides:
allowExpensiveQueries
in classQueryRewriteContext
-
hasAsyncActions
public boolean hasAsyncActions()Description copied from class:QueryRewriteContext
Returnstrue
if there are any registered async actions.- Overrides:
hasAsyncActions
in classQueryRewriteContext
-
getFullyQualifiedIndex
Description copied from class:QueryRewriteContext
Returns the fully qualified index including a remote cluster alias if applicable, and the index uuid- Overrides:
getFullyQualifiedIndex
in classQueryRewriteContext
-
getIndexSettings
Description copied from class:QueryRewriteContext
Returns the index settings for this context. This might return null if the context has not index scope.- Overrides:
getIndexSettings
in classQueryRewriteContext
-
indexMatches
Description copied from class:QueryRewriteContext
Given 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:
indexMatches
in classQueryRewriteContext
-
getMatchingFieldNames
Description copied from class:QueryRewriteContext
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)
- Overrides:
getMatchingFieldNames
in classQueryRewriteContext
- Parameters:
pattern
- the field name pattern
-
setRewriteToNamedQueries
public void setRewriteToNamedQueries()Description copied from class:SearchExecutionContext
Instructs to rewrite Elasticsearch queries with _name to Lucene NamedQuery- Overrides:
setRewriteToNamedQueries
in classSearchExecutionContext
-
rewriteToNamedQuery
public boolean rewriteToNamedQuery()Description copied from class:SearchExecutionContext
Returns true if Elasticsearch queries with _name must be rewritten to Lucene NamedQuery- Overrides:
rewriteToNamedQuery
in classSearchExecutionContext
- Returns:
-