Package org.elasticsearch.index.mapper
Class DateFieldMapper.DateFieldType
java.lang.Object
org.elasticsearch.index.mapper.MappedFieldType
org.elasticsearch.index.mapper.DateFieldMapper.DateFieldType
- Enclosing class:
- DateFieldMapper
public static final class DateFieldMapper.DateFieldType extends MappedFieldType
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.index.mapper.MappedFieldType
MappedFieldType.CollapseType, MappedFieldType.Relation
-
Field Summary
Fields Modifier and Type Field Description protected DateMathParser
dateMathParser
protected DateFormatter
dateTimeFormatter
protected java.lang.String
nullValue
protected DateFieldMapper.Resolution
resolution
protected FieldValues<java.lang.Long>
scriptValues
-
Constructor Summary
Constructors Constructor Description DateFieldType(java.lang.String name)
DateFieldType(java.lang.String name, boolean isSearchable, boolean isStored, boolean hasDocValues, DateFormatter dateTimeFormatter, DateFieldMapper.Resolution resolution, java.lang.String nullValue, FieldValues<java.lang.Long> scriptValues, java.util.Map<java.lang.String,java.lang.String> meta)
DateFieldType(java.lang.String name, DateFormatter dateFormatter)
DateFieldType(java.lang.String name, DateFieldMapper.Resolution resolution)
DateFieldType(java.lang.String name, DateFieldMapper.Resolution resolution, DateFormatter dateFormatter)
-
Method Summary
Modifier and Type Method Description protected DateMathParser
dateMathParser()
static org.apache.lucene.search.Query
dateRangeQuery(java.lang.Object lowerTerm, java.lang.Object upperTerm, boolean includeLower, boolean includeUpper, java.time.ZoneId timeZone, DateMathParser parser, SearchExecutionContext context, DateFieldMapper.Resolution resolution, java.util.function.BiFunction<java.lang.Long,java.lang.Long,org.apache.lucene.search.Query> builder)
DateFormatter
dateTimeFormatter()
org.apache.lucene.search.Query
distanceFeatureQuery(java.lang.Object origin, java.lang.String pivot, SearchExecutionContext context)
DocValueFormat
docValueFormat(java.lang.String format, java.time.ZoneId timeZone)
Return aDocValueFormat
that can be used to display and parse values as returned by the fielddata API.IndexFieldData.Builder
fielddataBuilder(java.lang.String fullyQualifiedIndexName, java.util.function.Supplier<SearchLookup> searchLookup)
Return a fielddata builder for this fieldstatic org.apache.lucene.search.Query
handleNow(SearchExecutionContext context, java.util.function.Function<java.util.function.LongSupplier,org.apache.lucene.search.Query> builder)
Handlenow
in queries.MappedFieldType.Relation
isFieldWithinQuery(long minValue, long maxValue, java.lang.Object from, java.lang.Object to, boolean includeLower, boolean includeUpper, java.time.ZoneId timeZone, DateMathParser dateParser, QueryRewriteContext context)
MappedFieldType.Relation
isFieldWithinQuery(org.apache.lucene.index.IndexReader reader, java.lang.Object from, java.lang.Object to, boolean includeLower, boolean includeUpper, java.time.ZoneId timeZone, DateMathParser dateParser, QueryRewriteContext context)
Return whether all values of the givenIndexReader
are within the range, outside the range or cross the range.long
parse(java.lang.String value)
long
parseToLong(java.lang.Object value, boolean roundUp, java.time.ZoneId zone, DateMathParser dateParser, java.util.function.LongSupplier now)
static long
parseToLong(java.lang.Object value, boolean roundUp, java.time.ZoneId zone, DateMathParser dateParser, java.util.function.LongSupplier now, DateFieldMapper.Resolution resolution)
java.util.function.Function<byte[],java.lang.Number>
pointReaderIfPossible()
If the field supports using the indexed data to speed up operations related to ordering of data, such as sorting or aggs, return a function for doing that.org.apache.lucene.search.Query
rangeQuery(java.lang.Object lowerTerm, java.lang.Object upperTerm, boolean includeLower, boolean includeUpper, ShapeRelation relation, java.time.ZoneId timeZone, DateMathParser forcedDateParser, SearchExecutionContext context)
Factory method for range queries.DateFieldMapper.Resolution
resolution()
org.apache.lucene.search.Query
termQuery(java.lang.Object value, SearchExecutionContext context)
Generates a query that will only match documents that contain the given value.java.lang.String
typeName()
Returns the name of this type, as would be specified in mapping propertiesValueFetcher
valueFetcher(SearchExecutionContext context, java.lang.String format)
Create a helper class to fetch field values during theFetchFieldsPhase
.java.lang.Object
valueForDisplay(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.elasticsearch.index.mapper.MappedFieldType
boost, collapseType, eagerGlobalOrdinals, existsQuery, extractTerm, failIfNoDocValues, failIfNotIndexed, familyTypeName, fuzzyQuery, getTextSearchInfo, hasDocValues, intervals, isAggregatable, isSearchable, isStored, meta, multiPhraseQuery, name, normalizedWildcardQuery, phrasePrefixQuery, phraseQuery, prefixQuery, prefixQuery, regexpQuery, setBoost, spanPrefixQuery, termQueryCaseInsensitive, termsQuery, wildcardQuery, wildcardQuery
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
dateTimeFormatter
-
dateMathParser
-
resolution
-
nullValue
protected final java.lang.String nullValue -
scriptValues
-
-
Constructor Details
-
DateFieldType
public DateFieldType(java.lang.String name, boolean isSearchable, boolean isStored, boolean hasDocValues, DateFormatter dateTimeFormatter, DateFieldMapper.Resolution resolution, java.lang.String nullValue, FieldValues<java.lang.Long> scriptValues, java.util.Map<java.lang.String,java.lang.String> meta) -
DateFieldType
public DateFieldType(java.lang.String name) -
DateFieldType
-
DateFieldType
-
DateFieldType
public DateFieldType(java.lang.String name, DateFieldMapper.Resolution resolution, DateFormatter dateFormatter)
-
-
Method Details
-
typeName
public java.lang.String typeName()Description copied from class:MappedFieldType
Returns the name of this type, as would be specified in mapping properties- Specified by:
typeName
in classMappedFieldType
-
dateTimeFormatter
-
resolution
-
dateMathParser
-
parse
public long parse(java.lang.String value) -
valueFetcher
Description copied from class:MappedFieldType
Create a helper class to fetch field values during theFetchFieldsPhase
.New field types must implement this method in order to support the search 'fields' option. Except for metadata fields, field types should not throw
UnsupportedOperationException
since this could cause a search retrieving multiple fields (like "fields": ["*"]) to fail.- Specified by:
valueFetcher
in classMappedFieldType
-
termQuery
public org.apache.lucene.search.Query termQuery(java.lang.Object value, @Nullable SearchExecutionContext 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
-
rangeQuery
public org.apache.lucene.search.Query rangeQuery(java.lang.Object lowerTerm, java.lang.Object upperTerm, boolean includeLower, boolean includeUpper, ShapeRelation relation, @Nullable java.time.ZoneId timeZone, @Nullable DateMathParser forcedDateParser, SearchExecutionContext context)Description copied from class:MappedFieldType
Factory method for range queries.- Overrides:
rangeQuery
in classMappedFieldType
relation
- the relation, nulls should be interpreted like INTERSECTS
-
dateRangeQuery
public static org.apache.lucene.search.Query dateRangeQuery(java.lang.Object lowerTerm, java.lang.Object upperTerm, boolean includeLower, boolean includeUpper, @Nullable java.time.ZoneId timeZone, DateMathParser parser, SearchExecutionContext context, DateFieldMapper.Resolution resolution, java.util.function.BiFunction<java.lang.Long,java.lang.Long,org.apache.lucene.search.Query> builder) -
handleNow
public static org.apache.lucene.search.Query handleNow(SearchExecutionContext context, java.util.function.Function<java.util.function.LongSupplier,org.apache.lucene.search.Query> builder)Handlenow
in queries.- Parameters:
context
- context from which to read the current timebuilder
- build the query- Returns:
- the result of the builder, wrapped in
DateRangeIncludingNowQuery
ifnow
was used.
-
parseToLong
public long parseToLong(java.lang.Object value, boolean roundUp, @Nullable java.time.ZoneId zone, DateMathParser dateParser, java.util.function.LongSupplier now) -
parseToLong
public static long parseToLong(java.lang.Object value, boolean roundUp, @Nullable java.time.ZoneId zone, DateMathParser dateParser, java.util.function.LongSupplier now, DateFieldMapper.Resolution resolution) -
distanceFeatureQuery
public org.apache.lucene.search.Query distanceFeatureQuery(java.lang.Object origin, java.lang.String pivot, SearchExecutionContext context)- Overrides:
distanceFeatureQuery
in classMappedFieldType
-
isFieldWithinQuery
public MappedFieldType.Relation isFieldWithinQuery(org.apache.lucene.index.IndexReader reader, java.lang.Object from, java.lang.Object to, boolean includeLower, boolean includeUpper, java.time.ZoneId timeZone, DateMathParser dateParser, QueryRewriteContext context) throws java.io.IOExceptionDescription copied from class:MappedFieldType
Return whether all values of the givenIndexReader
are 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.- Overrides:
isFieldWithinQuery
in classMappedFieldType
- Throws:
java.io.IOException
-
isFieldWithinQuery
public MappedFieldType.Relation isFieldWithinQuery(long minValue, long maxValue, java.lang.Object from, java.lang.Object to, boolean includeLower, boolean includeUpper, java.time.ZoneId timeZone, DateMathParser dateParser, QueryRewriteContext context) throws java.io.IOException- Throws:
java.io.IOException
-
pointReaderIfPossible
public java.util.function.Function<byte[],java.lang.Number> pointReaderIfPossible()Description copied from class:MappedFieldType
If the field supports using the indexed data to speed up operations related to ordering of data, such as sorting or aggs, return a function for doing that. If it is unsupported for this field type, there is no need to override this method.- Overrides:
pointReaderIfPossible
in classMappedFieldType
- Returns:
- null if the optimization cannot be applied, otherwise a function to use for the optimization
-
fielddataBuilder
public IndexFieldData.Builder fielddataBuilder(java.lang.String fullyQualifiedIndexName, java.util.function.Supplier<SearchLookup> searchLookup)Description copied from class:MappedFieldType
Return a fielddata builder for this field- Overrides:
fielddataBuilder
in classMappedFieldType
- Parameters:
fullyQualifiedIndexName
- the name of the index this field-data is build forsearchLookup
- aSearchLookup
supplier to allow for accessing other fields values in the context of runtime fields
-
valueForDisplay
public java.lang.Object valueForDisplay(java.lang.Object value)Description copied from class:MappedFieldType
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.- Overrides:
valueForDisplay
in classMappedFieldType
-
docValueFormat
Description copied from class:MappedFieldType
Return aDocValueFormat
that can be used to display and parse values as returned by the fielddata API. The default implementation returns aDocValueFormat.RAW
.- Overrides:
docValueFormat
in classMappedFieldType
-