java.lang.Object
org.elasticsearch.index.mapper.MappedFieldType
org.elasticsearch.index.mapper.ConstantFieldType
A
MappedFieldType that has the same value for all documents.
Factory methods for queries are called at rewrite time so they should be
cheap. In particular they should not read data from disk or perform a
network call. Furthermore they may only return a MatchAllDocsQuery
or a MatchNoDocsQuery.-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.index.mapper.MappedFieldType
MappedFieldType.BlockLoaderContext, MappedFieldType.CollapseType, MappedFieldType.FielddataOperation, MappedFieldType.FieldExtractPreference, MappedFieldType.Relation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.search.QueryautomatonQuery(Supplier<org.apache.lucene.util.automaton.Automaton> automatonSupplier, Supplier<org.apache.lucene.util.automaton.CharacterRunAutomaton> characterRunAutomatonSupplier, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, SearchExecutionContext context, String description) Returns a query that matches all documents or no documents depending on whether the constant value of this field matches or notfinal booleanfieldHasValue(org.apache.lucene.index.FieldInfos fieldInfos) This method is used to support _field_caps when include_empty_fields is set tofalse.abstract StringReturns the constant value of this field as a string.final org.apache.lucene.search.QueryinnerTermsQuery(Collection<?> values, QueryRewriteContext context) final org.apache.lucene.search.QueryinternalTermQuery(Object value, QueryRewriteContext context) final org.apache.lucene.search.QueryinternalTermQueryCaseInsensitive(Object value, QueryRewriteContext context) final booleanReturns true if the field is aggregatable.protected abstract booleanmatches(String pattern, boolean caseInsensitive, QueryRewriteContext context) Return whether the constant value of this field matches the providedpatternas documented inRegex.simpleMatch(java.lang.String, java.lang.String).final org.apache.lucene.search.QueryprefixQuery(String prefix, boolean caseInsensitive, QueryRewriteContext context) final org.apache.lucene.search.QueryprefixQuery(String prefix, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) final org.apache.lucene.search.QuerytermQuery(Object value, SearchExecutionContext context) Generates a query that will only match documents that contain the given value.final org.apache.lucene.search.QuerytermQueryCaseInsensitive(Object value, SearchExecutionContext context) final org.apache.lucene.search.QuerytermsQuery(Collection<?> values, SearchExecutionContext context) Build a constant-scoring query that matches all values.org.apache.lucene.search.QuerywildcardLikeQuery(String value, boolean caseInsensitive, QueryRewriteContext context) Returns a query that matches all documents or no documents It usually callswildcardQuery(String, boolean, QueryRewriteContext)except for IndexFieldType which overrides this method to use its own matching logic.final org.apache.lucene.search.QuerywildcardQuery(String value, boolean caseInsensitive, QueryRewriteContext context) final org.apache.lucene.search.QuerywildcardQuery(String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) Methods inherited from class org.elasticsearch.index.mapper.MappedFieldType
blockLoader, checkNoFormat, checkNoTimeZone, collapseType, dimensions, distanceFeatureQuery, docValueFormat, eagerGlobalOrdinals, existsQuery, failIfNoDocValues, failIfNotIndexed, failIfNotIndexedNorDocValuesFallback, familyTypeName, fielddataBuilder, fuzzyIntervals, fuzzyQuery, fuzzyQuery, getDefaultHighlighter, getMetricType, getTerms, getTextSearchInfo, hasDocValues, hasScriptValues, isDimension, isFieldWithinQuery, isIndexed, isSearchable, isStored, isVectorEmbedding, mayExistInIndex, meta, multiPhraseQuery, name, normalizedWildcardQuery, phrasePrefixQuery, phraseQuery, pointReaderIfPossible, prefixIntervals, prefixQuery, rangeIntervals, rangeQuery, regexpIntervals, regexpQuery, spanPrefixQuery, termIntervals, typeName, validateMatchedRoutingPath, valueFetcher, valueForDisplay, wildcardIntervals, wildcardLikeQuery, wildcardQuery
-
Constructor Details
-
ConstantFieldType
-
-
Method Details
-
isAggregatable
public final boolean isAggregatable()Description copied from class:MappedFieldTypeReturns true if the field is aggregatable.- Overrides:
isAggregatablein classMappedFieldType
-
matches
protected abstract boolean matches(String pattern, boolean caseInsensitive, QueryRewriteContext context) Return whether the constant value of this field matches the providedpatternas documented inRegex.simpleMatch(java.lang.String, java.lang.String). -
termQuery
Description copied from class:MappedFieldTypeGenerates a query that will only match documents that contain the given value. The default implementation returns aTermQueryover the value bytes- Specified by:
termQueryin classMappedFieldType
-
internalTermQuery
public final org.apache.lucene.search.Query internalTermQuery(Object value, QueryRewriteContext context) -
termQueryCaseInsensitive
public final org.apache.lucene.search.Query termQueryCaseInsensitive(Object value, SearchExecutionContext context) - Overrides:
termQueryCaseInsensitivein classMappedFieldType
-
internalTermQueryCaseInsensitive
public final org.apache.lucene.search.Query internalTermQueryCaseInsensitive(Object value, QueryRewriteContext context) -
termsQuery
public final org.apache.lucene.search.Query termsQuery(Collection<?> values, SearchExecutionContext context) Description copied from class:MappedFieldTypeBuild a constant-scoring query that matches all values. The default implementation uses aConstantScoreQueryaround aBooleanQuerywhoseBooleanClause.Occur.SHOULDclauses are generated withMappedFieldType.termQuery(java.lang.Object, org.elasticsearch.index.query.SearchExecutionContext).- Overrides:
termsQueryin classMappedFieldType
-
innerTermsQuery
public final org.apache.lucene.search.Query innerTermsQuery(Collection<?> values, QueryRewriteContext context) -
prefixQuery
public final org.apache.lucene.search.Query prefixQuery(String prefix, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) - Overrides:
prefixQueryin classMappedFieldType
-
prefixQuery
public final org.apache.lucene.search.Query prefixQuery(String prefix, boolean caseInsensitive, QueryRewriteContext context) -
wildcardQuery
public final org.apache.lucene.search.Query wildcardQuery(String value, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) - Overrides:
wildcardQueryin classMappedFieldType
-
wildcardQuery
public final org.apache.lucene.search.Query wildcardQuery(String value, boolean caseInsensitive, QueryRewriteContext context) -
wildcardLikeQuery
public org.apache.lucene.search.Query wildcardLikeQuery(String value, boolean caseInsensitive, QueryRewriteContext context) Returns a query that matches all documents or no documents It usually callswildcardQuery(String, boolean, QueryRewriteContext)except for IndexFieldType which overrides this method to use its own matching logic. -
fieldHasValue
public final boolean fieldHasValue(org.apache.lucene.index.FieldInfos fieldInfos) Description copied from class:MappedFieldTypeThis method is used to support _field_caps when include_empty_fields is set tofalse. In that case we return only fields with value in an index. This method gets as input FieldInfos and returns if the field is non-empty. This method needs to be overwritten where fields don't have footprint in Lucene or their name differs fromMappedFieldType.name()- Overrides:
fieldHasValuein classMappedFieldType- Parameters:
fieldInfos- field information- Returns:
trueif field is present in fieldInfosfalseotherwise
-
getConstantFieldValue
Returns the constant value of this field as a string. Based on the field type, we need to get it in a different way. -
automatonQuery
public org.apache.lucene.search.Query automatonQuery(Supplier<org.apache.lucene.util.automaton.Automaton> automatonSupplier, Supplier<org.apache.lucene.util.automaton.CharacterRunAutomaton> characterRunAutomatonSupplier, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod method, SearchExecutionContext context, String description) Returns a query that matches all documents or no documents depending on whether the constant value of this field matches or not- Overrides:
automatonQueryin classMappedFieldType
-