Package org.elasticsearch.index.mapper
Class ConstantFieldType
java.lang.Object
org.apache.lucene.document.FieldType
org.elasticsearch.index.mapper.MappedFieldType
org.elasticsearch.index.mapper.ConstantFieldType
- All Implemented Interfaces:
org.apache.lucene.index.IndexableFieldType
public abstract class ConstantFieldType extends MappedFieldType
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.Relation
-
Constructor Summary
Constructors Constructor Description ConstantFieldType()
ConstantFieldType(ConstantFieldType other)
-
Method Summary
Modifier and Type Method Description boolean
isAggregatable()
Returns true if the field is aggregatable.boolean
isSearchable()
Returns true if the field is searchable.protected abstract boolean
matches(java.lang.String pattern, QueryShardContext context)
Return whether the constant value of this field matches the providedpattern
as documented inRegex.simpleMatch(java.lang.String, java.lang.String)
.org.apache.lucene.search.Query
prefixQuery(java.lang.String prefix, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)
org.apache.lucene.search.Query
termQuery(java.lang.Object value, QueryShardContext context)
Generates a query that will only match documents that contain the given value.org.apache.lucene.search.Query
termsQuery(java.util.List<?> values, QueryShardContext context)
Build a constant-scoring query that matches all values.org.apache.lucene.search.Query
wildcardQuery(java.lang.String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)
Methods inherited from class org.elasticsearch.index.mapper.MappedFieldType
boost, checkCompatibility, clone, docValueFormat, eagerGlobalOrdinals, equals, existsQuery, extractTerm, failIfNoDocValues, failIfNotIndexed, fielddataBuilder, fuzzyQuery, hasDocValues, hashCode, indexAnalyzer, intervals, isFieldWithinQuery, meta, multiPhraseQuery, name, nullValue, nullValueAsString, phrasePrefixQuery, phraseQuery, rangeQuery, regexpQuery, searchAnalyzer, searchQuoteAnalyzer, setBoost, setEagerGlobalOrdinals, setHasDocValues, setIndexAnalyzer, setMeta, setName, setNullValue, setSearchAnalyzer, setSearchQuoteAnalyzer, setSimilarity, similarity, spanPrefixQuery, typeName, valueForDisplay
Methods inherited from class org.apache.lucene.document.FieldType
checkIfFrozen, docValuesType, freeze, getAttributes, indexOptions, omitNorms, pointDimensionCount, pointIndexDimensionCount, pointNumBytes, putAttribute, setDimensions, setDimensions, setDocValuesType, setIndexOptions, setOmitNorms, setStored, setStoreTermVectorOffsets, setStoreTermVectorPayloads, setStoreTermVectorPositions, setStoreTermVectors, setTokenized, stored, storeTermVectorOffsets, storeTermVectorPayloads, storeTermVectorPositions, storeTermVectors, tokenized, toString
-
Constructor Details
-
ConstantFieldType
public ConstantFieldType() -
ConstantFieldType
-
-
Method Details
-
isSearchable
public final boolean isSearchable()Description copied from class:MappedFieldType
Returns true if the field is searchable.- Overrides:
isSearchable
in classMappedFieldType
-
isAggregatable
public final boolean isAggregatable()Description copied from class:MappedFieldType
Returns true if the field is aggregatable.- Overrides:
isAggregatable
in classMappedFieldType
-
matches
Return whether the constant value of this field matches the providedpattern
as documented inRegex.simpleMatch(java.lang.String, java.lang.String)
. -
termQuery
public final org.apache.lucene.search.Query termQuery(java.lang.Object value, QueryShardContext context)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, boosted byMappedFieldType.boost()
.- Specified by:
termQuery
in classMappedFieldType
-
termsQuery
public final org.apache.lucene.search.Query termsQuery(java.util.List<?> values, QueryShardContext 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.QueryShardContext)
.- Overrides:
termsQuery
in classMappedFieldType
-
prefixQuery
public final org.apache.lucene.search.Query prefixQuery(java.lang.String prefix, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)- Overrides:
prefixQuery
in classMappedFieldType
-
wildcardQuery
public final org.apache.lucene.search.Query wildcardQuery(java.lang.String value, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)- Overrides:
wildcardQuery
in classMappedFieldType
-