Package org.opensearch.index.query
Class QueryShardContext
java.lang.Object
org.opensearch.index.query.QueryRewriteContext
org.opensearch.index.query.QueryShardContext
Context object used to create lucene queries on the shard level.
- Opensearch.internal:
-
Field Summary
Fields inherited from class org.opensearch.index.query.QueryRewriteContext
client, nowInMillis
-
Constructor Summary
ConstructorsConstructorDescriptionQueryShardContext
(int shardId, IndexSettings indexSettings, BigArrays bigArrays, BitsetFilterCache bitsetFilterCache, TriFunction<MappedFieldType, String, Supplier<SearchLookup>, IndexFieldData<?>> indexFieldDataLookup, MapperService mapperService, SimilarityService similarityService, ScriptService scriptService, org.opensearch.common.xcontent.NamedXContentRegistry xContentRegistry, NamedWriteableRegistry namedWriteableRegistry, Client client, org.apache.lucene.search.IndexSearcher searcher, LongSupplier nowInMillis, String clusterAlias, Predicate<String> indexNameMatcher, BooleanSupplier allowExpensiveQueries, ValuesSourceRegistry valuesSourceRegistry) QueryShardContext
(int shardId, IndexSettings indexSettings, BigArrays bigArrays, BitsetFilterCache bitsetFilterCache, TriFunction<MappedFieldType, String, Supplier<SearchLookup>, IndexFieldData<?>> indexFieldDataLookup, MapperService mapperService, SimilarityService similarityService, ScriptService scriptService, org.opensearch.common.xcontent.NamedXContentRegistry xContentRegistry, NamedWriteableRegistry namedWriteableRegistry, Client client, org.apache.lucene.search.IndexSearcher searcher, LongSupplier nowInMillis, String clusterAlias, Predicate<String> indexNameMatcher, BooleanSupplier allowExpensiveQueries, ValuesSourceRegistry valuesSourceRegistry, boolean validate) QueryShardContext
(QueryShardContext source) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNamedQuery
(String name, org.apache.lucene.search.Query query) boolean
Return theBigArrays
instance for this node.org.apache.lucene.search.join.BitSetProducer
bitsetFilter
(org.apache.lucene.search.Query filter) <FactoryType>
FactoryTypecompile
(Script script, ScriptContext<FactoryType> context) Compile script using script servicefinal QueryShardContext
Returns an instance ofQueryShardContext
if available of null otherwisedocumentMapper
(String type) Returns sDocumentMapper
instance.void
executeAsyncActions
(ActionListener listener) Executes all registered async actions and notifies the listener once it's done.protected final void
This method fails iffreezeContext()
is called before on this context.fieldMapper
(String name) final void
if this method is called the query context will throw exception if methods are accessed that could yield different results across executions likegetClient()
getFieldType
(String name) Returns theMappedFieldType
for the provided field name.<IFD extends IndexFieldData<?>>
IFDgetForField
(MappedFieldType fieldType) Returns the fully qualified index including a remote cluster alias if applicable, and the index uuidorg.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.Return the MapperService.getObjectMapper
(String name) org.apache.lucene.analysis.Analyzer
getSearchAnalyzer
(MappedFieldType fieldType) Gets the search analyzer for the given field, or the default if there is none present for the field TODO: remove this by moving defaults into mappers themselvesorg.apache.lucene.analysis.Analyzer
getSearchQuoteAnalyzer
(MappedFieldType fieldType) Gets the search quote analyzer for the given field, or the default if there is none present for the field TODO: remove this by moving defaults into mappers themselvesorg.apache.lucene.search.similarities.Similarity
int
Returns the shard ID this context was created for.index()
boolean
indexMatches
(String pattern) Given an index pattern, checks whether it matches against the current shard.boolean
indexSortedOnField
(String field) final boolean
Returnstrue
iff the result of the processed search request is cacheable.boolean
isMetadataField
(String field) lookup()
Get the lookup to use during the search.Build a lookup customized for the fetch phase.final long
Returns the time in milliseconds that is shared across all resources involved.parseInnerQueryBuilder
(org.opensearch.common.xcontent.XContentParser parser) 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.org.apache.lucene.search.IndexSearcher
searcher()
Return the currentIndexSearcher
, ornull
if no index reader is available, for instance if this rewrite context is used to index queries (percolation).void
setAllowUnmappedFields
(boolean allowUnmappedFields) void
setMapUnmappedFieldAsString
(boolean mapUnmappedFieldAsString) simpleMatchToIndexNames
(String pattern) Returns all the fields that match a given pattern.sourcePath
(String fullName) toQuery
(QueryBuilder queryBuilder) Methods inherited from class org.opensearch.index.query.QueryRewriteContext
getWriteableRegistry, getXContentRegistry, hasAsyncActions, validate
-
Constructor Details
-
QueryShardContext
public QueryShardContext(int shardId, IndexSettings indexSettings, BigArrays bigArrays, BitsetFilterCache bitsetFilterCache, TriFunction<MappedFieldType, String, Supplier<SearchLookup>, IndexFieldData<?>> indexFieldDataLookup, MapperService mapperService, SimilarityService similarityService, ScriptService scriptService, org.opensearch.common.xcontent.NamedXContentRegistry xContentRegistry, NamedWriteableRegistry namedWriteableRegistry, Client client, org.apache.lucene.search.IndexSearcher searcher, LongSupplier nowInMillis, String clusterAlias, Predicate<String> indexNameMatcher, BooleanSupplier allowExpensiveQueries, ValuesSourceRegistry valuesSourceRegistry) -
QueryShardContext
public QueryShardContext(int shardId, IndexSettings indexSettings, BigArrays bigArrays, BitsetFilterCache bitsetFilterCache, TriFunction<MappedFieldType, String, Supplier<SearchLookup>, IndexFieldData<?>> indexFieldDataLookup, MapperService mapperService, SimilarityService similarityService, ScriptService scriptService, org.opensearch.common.xcontent.NamedXContentRegistry xContentRegistry, NamedWriteableRegistry namedWriteableRegistry, Client client, org.apache.lucene.search.IndexSearcher searcher, LongSupplier nowInMillis, String clusterAlias, Predicate<String> indexNameMatcher, BooleanSupplier allowExpensiveQueries, ValuesSourceRegistry valuesSourceRegistry, boolean validate) -
QueryShardContext
-
-
Method Details
-
getIndexAnalyzers
-
getSearchSimilarity
public org.apache.lucene.search.similarities.Similarity getSearchSimilarity() -
defaultFields
-
queryStringLenient
public boolean queryStringLenient() -
queryStringAnalyzeWildcard
public boolean queryStringAnalyzeWildcard() -
queryStringAllowLeadingWildcard
public boolean queryStringAllowLeadingWildcard() -
bitsetFilter
public org.apache.lucene.search.join.BitSetProducer bitsetFilter(org.apache.lucene.search.Query filter) -
allowExpensiveQueries
public boolean allowExpensiveQueries() -
getForField
-
addNamedQuery
-
copyNamedQueries
-
simpleMatchToIndexNames
Returns all the fields that match a given pattern. If prefixed with a type then the fields will be returned with a type prefix. -
getFieldType
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.- Throws:
QueryShardException
- if unmapped fields are not allowed and automatically mapping unmapped fields as text is disabled.- See Also:
-
fieldMapper
-
getObjectMapper
-
isMetadataField
-
sourcePath
-
documentMapper
Returns sDocumentMapper
instance. Delegates toMapperService.documentMapper()
-
getSearchAnalyzer
Gets the search analyzer for the given field, or the default if there is none present for the field TODO: remove this by moving defaults into mappers themselves -
getSearchQuoteAnalyzer
Gets the search quote analyzer for the given field, or the default if there is none present for the field TODO: remove this by moving defaults into mappers themselves -
getValuesSourceRegistry
-
setAllowUnmappedFields
public void setAllowUnmappedFields(boolean allowUnmappedFields) -
setMapUnmappedFieldAsString
public void setMapUnmappedFieldAsString(boolean mapUnmappedFieldAsString) -
lookup
Get the lookup to use during the search. -
newFetchLookup
Build a lookup customized for the fetch phase. Uselookup()
in other phases. -
nestedScope
-
indexVersionCreated
-
indexMatches
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. -
indexSortedOnField
-
toQuery
-
index
-
compile
Compile script using script service -
freezeContext
public final void freezeContext()if this method is called the query context will throw exception if methods are accessed that could yield different results across executions likegetClient()
-
failIfFrozen
protected final void failIfFrozen()This method fails iffreezeContext()
is called before on this context. This is used to seal. This methods and all methods that call it should be final to ensure that setting the request as not cacheable and the freezing behaviour of this class cannot be bypassed. This is important so we can trust when this class says a request can be cached. -
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 rewriteabel needs to fetch some external resources in order to be executed ie. a document from an index.- Overrides:
registerAsyncAction
in classQueryRewriteContext
-
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 classQueryRewriteContext
-
isCacheable
public final boolean isCacheable()Returnstrue
iff the result of the processed search request is cacheable. Otherwisefalse
-
getShardId
public int getShardId()Returns the shard ID this context was created for. -
nowInMillis
public final long nowInMillis()Description copied from class:QueryRewriteContext
Returns the time in milliseconds that is shared across all resources involved. Even across shards and nodes.- Overrides:
nowInMillis
in classQueryRewriteContext
-
getClient
-
parseInnerQueryBuilder
public QueryBuilder parseInnerQueryBuilder(org.opensearch.common.xcontent.XContentParser parser) throws IOException - Throws:
IOException
-
convertToShardContext
Description copied from class:QueryRewriteContext
Returns an instance ofQueryShardContext
if available of null otherwise- Overrides:
convertToShardContext
in classQueryRewriteContext
-
getIndexSettings
Returns the index settings for this context. This might return null if the context has not index scope. -
getMapperService
Return the MapperService. -
getIndexReader
public org.apache.lucene.index.IndexReader getIndexReader()Return the currentIndexReader
, ornull
if no index reader is available, for instance if this rewrite context is used to index queries (percolation). -
searcher
public org.apache.lucene.search.IndexSearcher searcher()Return the currentIndexSearcher
, ornull
if no index reader is available, for instance if this rewrite context is used to index queries (percolation). -
getFullyQualifiedIndex
Returns the fully qualified index including a remote cluster alias if applicable, and the index uuid -
bigArrays
Return theBigArrays
instance for this node. -
getSimilarityService
-
getBitsetFilterCache
-
getUsageService
-