public class QueryShardContext extends QueryRewriteContext
client, nowInMillis, reader, scriptService
Constructor and Description |
---|
QueryShardContext(int shardId,
IndexSettings indexSettings,
BitsetFilterCache bitsetFilterCache,
IndexFieldDataService indexFieldDataService,
MapperService mapperService,
SimilarityService similarityService,
ScriptService scriptService,
NamedXContentRegistry xContentRegistry,
Client client,
org.apache.lucene.index.IndexReader reader,
java.util.function.LongSupplier nowInMillis) |
QueryShardContext(QueryShardContext source) |
Modifier and Type | Method and Description |
---|---|
void |
addNamedQuery(java.lang.String name,
org.apache.lucene.search.Query query) |
org.apache.lucene.search.join.BitSetProducer |
bitsetFilter(org.apache.lucene.search.Query filter) |
java.util.Map<java.lang.String,org.apache.lucene.search.Query> |
copyNamedQueries() |
java.lang.String |
defaultField() |
DocumentMapper |
documentMapper(java.lang.String type)
Returns s
DocumentMapper instance for the given type. |
protected void |
failIfFrozen()
This method fails if
freezeContext() is called before on this
context. |
MappedFieldType |
fieldMapper(java.lang.String name) |
void |
freezeContext()
if this method is called the query context will throw exception if methods are accessed
that could yield different results across executions like
getTemplateBytes(Script) |
Client |
getClient()
Returns a clients to fetch resources from local or remove nodes.
|
ExecutableScript |
getExecutableScript(Script script,
ScriptContext context)
Compiles (or retrieves from cache) and binds the parameters to the
provided script
|
<IFD extends IndexFieldData<?>> |
getForField(MappedFieldType mapper) |
IndexAnalyzers |
getIndexAnalyzers() |
java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,ExecutableScript> |
getLazyExecutableScript(Script script,
ScriptContext context)
Returns a lazily created
ExecutableScript that is compiled immediately but can be pulled later once all
parameters are available. |
java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,SearchScript> |
getLazySearchScript(Script script,
ScriptContext context)
Returns a lazily created
SearchScript that is compiled immediately but can be pulled later once all
parameters are available. |
ObjectMapper |
getObjectMapper(java.lang.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 themselves
|
org.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 themselves
|
SearchScript |
getSearchScript(Script script,
ScriptContext context)
Compiles (or retrieves from cache) and binds the parameters to the
provided script
|
org.apache.lucene.search.similarities.Similarity |
getSearchSimilarity() |
int |
getShardId()
Returns the shard ID this context was created for.
|
BytesReference |
getTemplateBytes(Script template) |
java.lang.String[] |
getTypes() |
Index |
index() |
Version |
indexVersionCreated() |
boolean |
isCachable()
Returns
true iff the result of the processed search request is cachable. |
boolean |
isFilter()
Return whether we are currently parsing a filter or a query.
|
SearchLookup |
lookup() |
boolean |
matchesIndices(java.lang.String... indices) |
NestedScope |
nestedScope() |
long |
nowInMillis() |
MapperQueryParser |
queryParser(QueryParserSettings settings) |
boolean |
queryStringAllowLeadingWildcard() |
boolean |
queryStringAnalyzeWildcard() |
boolean |
queryStringLenient() |
java.util.Collection<java.lang.String> |
queryTypes()
Returns the narrowed down explicit types, or, if not set, all types.
|
void |
setAllowUnmappedFields(boolean allowUnmappedFields) |
void |
setIsFilter(boolean isFilter)
Public for testing only!
Sets whether we are currently parsing a filter or a query
|
void |
setMapUnmappedFieldAsString(boolean mapUnmappedFieldAsString) |
void |
setTypes(java.lang.String... types) |
java.util.Collection<java.lang.String> |
simpleMatchToIndexNames(java.lang.String pattern)
Returns all the fields that match a given pattern.
|
ParsedQuery |
toFilter(QueryBuilder queryBuilder) |
ParsedQuery |
toQuery(QueryBuilder queryBuilder) |
getIndexReader, getIndexSettings, getMapperService, getXContentRegistry, newParseContext, newParseContextWithLegacyScriptLanguage
public QueryShardContext(int shardId, IndexSettings indexSettings, BitsetFilterCache bitsetFilterCache, IndexFieldDataService indexFieldDataService, MapperService mapperService, SimilarityService similarityService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Client client, org.apache.lucene.index.IndexReader reader, java.util.function.LongSupplier nowInMillis)
public QueryShardContext(QueryShardContext source)
public void setTypes(java.lang.String... types)
public java.lang.String[] getTypes()
public IndexAnalyzers getIndexAnalyzers()
public org.apache.lucene.search.similarities.Similarity getSearchSimilarity()
public java.lang.String defaultField()
public boolean queryStringLenient()
public boolean queryStringAnalyzeWildcard()
public boolean queryStringAllowLeadingWildcard()
public MapperQueryParser queryParser(QueryParserSettings settings)
public org.apache.lucene.search.join.BitSetProducer bitsetFilter(org.apache.lucene.search.Query filter)
public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType mapper)
public void addNamedQuery(java.lang.String name, org.apache.lucene.search.Query query)
public java.util.Map<java.lang.String,org.apache.lucene.search.Query> copyNamedQueries()
public boolean isFilter()
public void setIsFilter(boolean isFilter)
public java.util.Collection<java.lang.String> simpleMatchToIndexNames(java.lang.String pattern)
public MappedFieldType fieldMapper(java.lang.String name)
public ObjectMapper getObjectMapper(java.lang.String name)
public DocumentMapper documentMapper(java.lang.String type)
DocumentMapper
instance for the given type.
Delegates to MapperService.documentMapper(String)
public org.apache.lucene.analysis.Analyzer getSearchAnalyzer(MappedFieldType fieldType)
public org.apache.lucene.analysis.Analyzer getSearchQuoteAnalyzer(MappedFieldType fieldType)
public void setAllowUnmappedFields(boolean allowUnmappedFields)
public void setMapUnmappedFieldAsString(boolean mapUnmappedFieldAsString)
public java.util.Collection<java.lang.String> queryTypes()
public SearchLookup lookup()
public NestedScope nestedScope()
public Version indexVersionCreated()
public boolean matchesIndices(java.lang.String... indices)
public ParsedQuery toFilter(QueryBuilder queryBuilder)
public ParsedQuery toQuery(QueryBuilder queryBuilder)
public final Index index()
public final SearchScript getSearchScript(Script script, ScriptContext context)
public final java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,SearchScript> getLazySearchScript(Script script, ScriptContext context)
SearchScript
that is compiled immediately but can be pulled later once all
parameters are available.public final ExecutableScript getExecutableScript(Script script, ScriptContext context)
public final java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,ExecutableScript> getLazyExecutableScript(Script script, ScriptContext context)
ExecutableScript
that is compiled immediately but can be pulled later once all
parameters are available.public final void freezeContext()
getTemplateBytes(Script)
protected final void failIfFrozen()
freezeContext()
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.public final BytesReference getTemplateBytes(Script template)
getTemplateBytes
in class QueryRewriteContext
public final boolean isCachable()
true
iff the result of the processed search request is cachable. Otherwise false
public int getShardId()
public final long nowInMillis()
nowInMillis
in class QueryRewriteContext
public Client getClient()
QueryRewriteContext
getClient
in class QueryRewriteContext