Package org.elasticsearch.index.mapper
Class MappedFieldType
- java.lang.Object
-
- org.apache.lucene.document.FieldType
-
- org.elasticsearch.index.mapper.MappedFieldType
-
- All Implemented Interfaces:
org.apache.lucene.index.IndexableFieldType
- Direct Known Subclasses:
DateFieldMapper.DateFieldType,GeoPointFieldMapper.GeoPointFieldType,GeoShapeFieldMapper.GeoShapeFieldType,RangeFieldMapper.RangeFieldType,SimpleMappedFieldType
public abstract class MappedFieldType extends org.apache.lucene.document.FieldTypeThis defines the core properties and functions to operate on a field.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMappedFieldType.RelationAn enum used to describe the relation between the range of terms in a shard when compared with a query range
-
Constructor Summary
Constructors Modifier Constructor Description MappedFieldType()protectedMappedFieldType(MappedFieldType ref)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description floatboost()voidcheckCompatibility(MappedFieldType other, java.util.List<java.lang.String> conflicts, boolean strict)Checks for any conflicts between this field type and other.abstract MappedFieldTypeclone()DocValueFormatdocValueFormat(java.lang.String format, org.joda.time.DateTimeZone timeZone)Return aDocValueFormatthat can be used to display and parse values as returned by the fielddata API.booleaneagerGlobalOrdinals()booleanequals(java.lang.Object o)abstract org.apache.lucene.search.QueryexistsQuery(QueryShardContext context)static org.apache.lucene.index.TermextractTerm(org.apache.lucene.search.Query termQuery)Extract aTermfrom a query created withtermQuery(java.lang.Object, org.elasticsearch.index.query.QueryShardContext)by recursively removingBoostQuerywrappers.protected voidfailIfNoDocValues()protected voidfailIfNotIndexed()IndexFieldData.BuilderfielddataBuilder(java.lang.String fullyQualifiedIndexName)Return a fielddata builder for this fieldorg.apache.lucene.search.QueryfuzzyQuery(java.lang.Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions)booleanhasDocValues()inthashCode()NamedAnalyzerindexAnalyzer()booleanisAggregatable()Returns true if the field is aggregatable.MappedFieldType.RelationisFieldWithinQuery(org.apache.lucene.index.IndexReader reader, java.lang.Object from, java.lang.Object to, boolean includeLower, boolean includeUpper, org.joda.time.DateTimeZone timeZone, DateMathParser dateMathParser, QueryRewriteContext context)Return whether all values of the givenIndexReaderare within the range, outside the range or cross the range.booleanisSearchable()Returns true if the field is searchable.org.apache.lucene.search.QuerymultiPhraseQuery(java.lang.String field, org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements)java.lang.Stringname()java.lang.ObjectnullValue()Returns the value that should be added when JSON null is found, or null if no value should be addedjava.lang.StringnullValueAsString()Returns the null value stringified, so it can be used for e.g.org.apache.lucene.search.QuerynullValueQuery()org.apache.lucene.search.QueryphraseQuery(java.lang.String field, org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements)org.apache.lucene.search.QueryprefixQuery(java.lang.String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)org.apache.lucene.search.QueryqueryStringTermQuery(org.apache.lucene.index.Term term)A term query to use when parsing a query string.org.apache.lucene.search.QueryrangeQuery(java.lang.Object lowerTerm, java.lang.Object upperTerm, boolean includeLower, boolean includeUpper, ShapeRelation relation, org.joda.time.DateTimeZone timeZone, DateMathParser parser, QueryShardContext context)Factory method for range queries.org.apache.lucene.search.QueryregexpQuery(java.lang.String value, int flags, int maxDeterminizedStates, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)NamedAnalyzersearchAnalyzer()NamedAnalyzersearchQuoteAnalyzer()voidsetBoost(float boost)voidsetEagerGlobalOrdinals(boolean eagerGlobalOrdinals)voidsetHasDocValues(boolean hasDocValues)voidsetIndexAnalyzer(NamedAnalyzer analyzer)voidsetName(java.lang.String name)voidsetNullValue(java.lang.Object nullValue)Sets the null value and initializes the string versionvoidsetSearchAnalyzer(NamedAnalyzer analyzer)voidsetSearchQuoteAnalyzer(NamedAnalyzer analyzer)voidsetSimilarity(SimilarityProvider similarity)SimilarityProvidersimilarity()abstract org.apache.lucene.search.QuerytermQuery(java.lang.Object value, QueryShardContext context)Generates a query that will only match documents that contain the given value.org.apache.lucene.search.QuerytermsQuery(java.util.List<?> values, QueryShardContext context)Build a constant-scoring query that matches all values.abstract java.lang.StringtypeName()Returns the name of this type, as would be specified in mapping propertiesjava.lang.ObjectvalueForDisplay(java.lang.Object value)Given a value that comes from the stored fields API, convert it to the expected type.-
Methods inherited from class org.apache.lucene.document.FieldType
checkIfFrozen, docValuesType, freeze, indexOptions, omitNorms, pointDimensionCount, pointNumBytes, setDimensions, setDocValuesType, setIndexOptions, setOmitNorms, setStored, setStoreTermVectorOffsets, setStoreTermVectorPayloads, setStoreTermVectorPositions, setStoreTermVectors, setTokenized, stored, storeTermVectorOffsets, storeTermVectorPayloads, storeTermVectorPositions, storeTermVectors, tokenized, toString
-
-
-
-
Constructor Detail
-
MappedFieldType
protected MappedFieldType(MappedFieldType ref)
-
MappedFieldType
public MappedFieldType()
-
-
Method Detail
-
clone
public abstract MappedFieldType clone()
- Overrides:
clonein classjava.lang.Object
-
fielddataBuilder
public IndexFieldData.Builder fielddataBuilder(java.lang.String fullyQualifiedIndexName)
Return a fielddata builder for this field- Parameters:
fullyQualifiedIndexName- the name of the index this field-data is build for- Throws:
java.lang.IllegalArgumentException- if the fielddata is not supported on this type. An IllegalArgumentException is needed in order to return an http error 400 when this error occurs in a request. see:ExceptionsHelper.status(java.lang.Throwable)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classorg.apache.lucene.document.FieldType
-
hashCode
public int hashCode()
- Overrides:
hashCodein classorg.apache.lucene.document.FieldType
-
typeName
public abstract java.lang.String typeName()
Returns the name of this type, as would be specified in mapping properties
-
checkCompatibility
public void checkCompatibility(MappedFieldType other, java.util.List<java.lang.String> conflicts, boolean strict)
Checks for any conflicts between this field type and other. If strict is true, all properties must be equal. Otherwise, only properties which must never change in an index are checked.
-
name
public java.lang.String name()
-
setName
public void setName(java.lang.String name)
-
boost
public float boost()
-
setBoost
public void setBoost(float boost)
-
hasDocValues
public boolean hasDocValues()
-
setHasDocValues
public void setHasDocValues(boolean hasDocValues)
-
indexAnalyzer
public NamedAnalyzer indexAnalyzer()
-
setIndexAnalyzer
public void setIndexAnalyzer(NamedAnalyzer analyzer)
-
searchAnalyzer
public NamedAnalyzer searchAnalyzer()
-
setSearchAnalyzer
public void setSearchAnalyzer(NamedAnalyzer analyzer)
-
searchQuoteAnalyzer
public NamedAnalyzer searchQuoteAnalyzer()
-
setSearchQuoteAnalyzer
public void setSearchQuoteAnalyzer(NamedAnalyzer analyzer)
-
similarity
public SimilarityProvider similarity()
-
setSimilarity
public void setSimilarity(SimilarityProvider similarity)
-
nullValue
public java.lang.Object nullValue()
Returns the value that should be added when JSON null is found, or null if no value should be added
-
nullValueAsString
public java.lang.String nullValueAsString()
Returns the null value stringified, so it can be used for e.g. _all field, or null if there is no null value
-
setNullValue
public void setNullValue(java.lang.Object nullValue)
Sets the null value and initializes the string version
-
valueForDisplay
public java.lang.Object valueForDisplay(java.lang.Object value)
Given a value that comes from the stored fields API, convert it to the expected type. For instance a date field would store dates as longs and format it back to a string in this method.
-
isSearchable
public boolean isSearchable()
Returns true if the field is searchable.
-
isAggregatable
public boolean isAggregatable()
Returns true if the field is aggregatable.
-
termQuery
public abstract org.apache.lucene.search.Query termQuery(java.lang.Object value, @Nullable QueryShardContext context)Generates a query that will only match documents that contain the given value. The default implementation returns aTermQueryover the value bytes, boosted byboost().- Throws:
java.lang.IllegalArgumentException- ifvaluecannot be converted to the expected data type
-
termsQuery
public org.apache.lucene.search.Query termsQuery(java.util.List<?> values, @Nullable QueryShardContext context)Build a constant-scoring query that matches all values. The default implementation uses aConstantScoreQueryaround aBooleanQuerywhoseBooleanClause.Occur.SHOULDclauses are generated withtermQuery(java.lang.Object, org.elasticsearch.index.query.QueryShardContext).
-
rangeQuery
public org.apache.lucene.search.Query rangeQuery(java.lang.Object lowerTerm, java.lang.Object upperTerm, boolean includeLower, boolean includeUpper, ShapeRelation relation, org.joda.time.DateTimeZone timeZone, DateMathParser parser, QueryShardContext context)Factory method for range queries.- Parameters:
relation- the relation, nulls should be interpreted like INTERSECTS
-
fuzzyQuery
public org.apache.lucene.search.Query fuzzyQuery(java.lang.Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions)
-
prefixQuery
public org.apache.lucene.search.Query prefixQuery(java.lang.String value, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)
-
regexpQuery
public org.apache.lucene.search.Query regexpQuery(java.lang.String value, int flags, int maxDeterminizedStates, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)
-
nullValueQuery
public org.apache.lucene.search.Query nullValueQuery()
-
existsQuery
public abstract org.apache.lucene.search.Query existsQuery(QueryShardContext context)
-
phraseQuery
public org.apache.lucene.search.Query phraseQuery(java.lang.String field, org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements) throws java.io.IOException- Throws:
java.io.IOException
-
multiPhraseQuery
public org.apache.lucene.search.Query multiPhraseQuery(java.lang.String field, org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements) throws java.io.IOException- Throws:
java.io.IOException
-
isFieldWithinQuery
public MappedFieldType.Relation isFieldWithinQuery(org.apache.lucene.index.IndexReader reader, java.lang.Object from, java.lang.Object to, boolean includeLower, boolean includeUpper, org.joda.time.DateTimeZone timeZone, DateMathParser dateMathParser, QueryRewriteContext context) throws java.io.IOException
Return whether all values of the givenIndexReaderare within the range, outside the range or cross the range. The default implementation returnsMappedFieldType.Relation.INTERSECTS, which is always fine to return when there is no way to check whether values are actually within bounds.- Throws:
java.io.IOException
-
queryStringTermQuery
@Nullable public org.apache.lucene.search.Query queryStringTermQuery(org.apache.lucene.index.Term term)
A term query to use when parsing a query string. Can returnnull.
-
failIfNoDocValues
protected final void failIfNoDocValues()
- Throws:
java.lang.IllegalArgumentException- if the fielddata is not supported on this type. An IllegalArgumentException is needed in order to return an http error 400 when this error occurs in a request. see:ExceptionsHelper.status(java.lang.Throwable)
-
failIfNotIndexed
protected final void failIfNotIndexed()
-
eagerGlobalOrdinals
public boolean eagerGlobalOrdinals()
-
setEagerGlobalOrdinals
public void setEagerGlobalOrdinals(boolean eagerGlobalOrdinals)
-
docValueFormat
public DocValueFormat docValueFormat(@Nullable java.lang.String format, org.joda.time.DateTimeZone timeZone)
Return aDocValueFormatthat can be used to display and parse values as returned by the fielddata API. The default implementation returns aDocValueFormat.RAW.
-
extractTerm
public static org.apache.lucene.index.Term extractTerm(org.apache.lucene.search.Query termQuery)
Extract aTermfrom a query created withtermQuery(java.lang.Object, org.elasticsearch.index.query.QueryShardContext)by recursively removingBoostQuerywrappers.- Throws:
java.lang.IllegalArgumentException- if the wrapped query is not aTermQuery
-
-