public class QueryShardContext extends QueryRewriteContext
client, clusterState, reader, scriptService
Constructor and Description |
---|
QueryShardContext(IndexSettings indexSettings,
BitsetFilterCache bitsetFilterCache,
IndexFieldDataService indexFieldDataService,
MapperService mapperService,
SimilarityService similarityService,
ScriptService scriptService,
IndicesQueriesRegistry indicesQueriesRegistry,
Client client,
org.apache.lucene.index.IndexReader reader,
ClusterState clusterState,
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() |
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) |
AnalysisService |
getAnalysisService() |
Client |
getClient()
Returns a clients to fetch resources from local or remove nodes.
|
ExecutableScript |
getExecutableScript(Script script,
ScriptContext context,
java.util.Map<java.lang.String,java.lang.String> params)
Compiles (or retrieves from cache) and binds the parameters to the
provided script
|
<IFD extends IndexFieldData<?>> |
getForField(MappedFieldType mapper) |
java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,ExecutableScript> |
getLazyExecutableScript(Script script,
ScriptContext context,
java.util.Map<java.lang.String,java.lang.String> params)
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,
java.util.Map<java.lang.String,java.lang.String> params)
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,
java.util.Map<java.lang.String,java.lang.String> params)
Compiles (or retrieves from cache) and binds the parameters to the
provided script
|
org.apache.lucene.search.similarities.Similarity |
getSearchSimilarity() |
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) |
ParsedQuery |
toFilter(QueryBuilder queryBuilder) |
ParsedQuery |
toQuery(QueryBuilder queryBuilder) |
getClusterState, getIndexReader, getIndexSettings, getMapperService, getParseFieldMatcher, newParseContext, newParseContextWithLegacyScriptLanguage
public QueryShardContext(IndexSettings indexSettings, BitsetFilterCache bitsetFilterCache, IndexFieldDataService indexFieldDataService, MapperService mapperService, SimilarityService similarityService, ScriptService scriptService, IndicesQueriesRegistry indicesQueriesRegistry, Client client, org.apache.lucene.index.IndexReader reader, ClusterState clusterState, java.util.function.LongSupplier nowInMillis)
public QueryShardContext(QueryShardContext source)
public void setTypes(java.lang.String... types)
public java.lang.String[] getTypes()
public AnalysisService getAnalysisService()
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 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 long nowInMillis()
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 SearchScript getSearchScript(Script script, ScriptContext context, java.util.Map<java.lang.String,java.lang.String> params)
public java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,SearchScript> getLazySearchScript(Script script, ScriptContext context, java.util.Map<java.lang.String,java.lang.String> params)
SearchScript
that is compiled immediately but can be pulled later once all
parameters are available.public ExecutableScript getExecutableScript(Script script, ScriptContext context, java.util.Map<java.lang.String,java.lang.String> params)
public java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,ExecutableScript> getLazyExecutableScript(Script script, ScriptContext context, java.util.Map<java.lang.String,java.lang.String> params)
ExecutableScript
that is compiled immediately but can be pulled later once all
parameters are available.public void freezeContext()
getTemplateBytes(Script)
protected void failIfFrozen()
freezeContext()
is called before on this context.
This is used to sealpublic BytesReference getTemplateBytes(Script template)
getTemplateBytes
in class QueryRewriteContext
public boolean isCachable()
true
iff the result of the processed search request is cachable. Otherwise false
public Client getClient()
QueryRewriteContext
getClient
in class QueryRewriteContext