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
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
fieldHasValue
(org.apache.lucene.index.FieldInfos fieldInfos) This method is used to support _field_caps when include_empty_fields is set tofalse
.final org.apache.lucene.search.Query
innerTermsQuery
(Collection<?> values, QueryRewriteContext context) final org.apache.lucene.search.Query
internalTermQuery
(Object value, QueryRewriteContext context) final org.apache.lucene.search.Query
internalTermQueryCaseInsensitive
(Object value, QueryRewriteContext context) final boolean
Returns true if the field is aggregatable.protected abstract boolean
matches
(String pattern, boolean caseInsensitive, QueryRewriteContext context) Return whether the constant value of this field matches the providedpattern
as documented inRegex.simpleMatch(java.lang.String, java.lang.String)
.final org.apache.lucene.search.Query
prefixQuery
(String prefix, boolean caseInsensitive, QueryRewriteContext context) final org.apache.lucene.search.Query
prefixQuery
(String prefix, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) final org.apache.lucene.search.Query
termQuery
(Object value, SearchExecutionContext context) Generates a query that will only match documents that contain the given value.final org.apache.lucene.search.Query
termQueryCaseInsensitive
(Object value, SearchExecutionContext context) final org.apache.lucene.search.Query
termsQuery
(Collection<?> values, SearchExecutionContext context) Build a constant-scoring query that matches all values.final org.apache.lucene.search.Query
wildcardQuery
(String value, boolean caseInsensitive, QueryRewriteContext context) final org.apache.lucene.search.Query
wildcardQuery
(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, extractTerm, failIfNoDocValues, failIfNotIndexed, failIfNotIndexedNorDocValuesFallback, familyTypeName, fielddataBuilder, fuzzyIntervals, fuzzyQuery, fuzzyQuery, getMetricType, getTerms, getTextSearchInfo, hasDocValues, isDimension, isFieldWithinQuery, isIndexed, isSearchable, isStored, mayExistInIndex, meta, multiPhraseQuery, name, normalizedWildcardQuery, phrasePrefixQuery, phraseQuery, pointReaderIfPossible, prefixIntervals, prefixQuery, rangeQuery, regexpQuery, spanPrefixQuery, termIntervals, typeName, validateMatchedRoutingPath, valueFetcher, valueForDisplay, wildcardIntervals, wildcardQuery
-
Constructor Details
-
ConstantFieldType
-
-
Method Details
-
isAggregatable
public final boolean isAggregatable()Description copied from class:MappedFieldType
Returns true if the field is aggregatable.- Overrides:
isAggregatable
in classMappedFieldType
-
matches
protected abstract boolean matches(String pattern, boolean caseInsensitive, QueryRewriteContext context) Return whether the constant value of this field matches the providedpattern
as documented inRegex.simpleMatch(java.lang.String, java.lang.String)
. -
termQuery
Description copied from class:MappedFieldType
Generates a query that will only match documents that contain the given value. The default implementation returns aTermQuery
over the value bytes- Specified by:
termQuery
in 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:
termQueryCaseInsensitive
in 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:MappedFieldType
Build a constant-scoring query that matches all values. The default implementation uses aConstantScoreQuery
around aBooleanQuery
whoseBooleanClause.Occur.SHOULD
clauses are generated withMappedFieldType.termQuery(java.lang.Object, org.elasticsearch.index.query.SearchExecutionContext)
.- Overrides:
termsQuery
in 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:
prefixQuery
in 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:
wildcardQuery
in classMappedFieldType
-
wildcardQuery
public final org.apache.lucene.search.Query wildcardQuery(String value, boolean caseInsensitive, QueryRewriteContext context) -
fieldHasValue
public final boolean fieldHasValue(org.apache.lucene.index.FieldInfos fieldInfos) Description copied from class:MappedFieldType
This 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:
fieldHasValue
in classMappedFieldType
- Parameters:
fieldInfos
- field information- Returns:
true
if field is present in fieldInfosfalse
otherwise
-