Module org.elasticsearch.server
Package org.elasticsearch.index.mapper
Class AbstractScriptFieldType<LeafFactory>
java.lang.Object
org.elasticsearch.index.mapper.MappedFieldType
org.elasticsearch.index.mapper.AbstractScriptFieldType<LeafFactory>
- Direct Known Subclasses:
BooleanScriptFieldType
,DateScriptFieldType
,DoubleScriptFieldType
,GeoPointScriptFieldType
,IpScriptFieldType
,KeywordScriptFieldType
,LongScriptFieldType
Abstract base MappedFieldType for runtime fields based on a script.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.elasticsearch.index.mapper.MappedFieldType
MappedFieldType.BlockLoaderContext, MappedFieldType.CollapseType, MappedFieldType.FielddataOperation, MappedFieldType.FieldExtractPreference, MappedFieldType.Relation
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractScriptFieldType
(String name, Function<SearchLookup, LeafFactory> factory, Script script, boolean isResultDeterministic, Map<String, String> meta) -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
applyScriptContext
(SearchExecutionContext context) final boolean
fieldHasValue
(org.apache.lucene.index.FieldInfos fieldInfos) This method is used to support _field_caps when include_empty_fields is set tofalse
.org.apache.lucene.search.Query
fuzzyQuery
(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions, SearchExecutionContext context, org.apache.lucene.search.MultiTermQuery.RewriteMethod rewriteMethod) final boolean
Returns true if the field is aggregatable.final boolean
Returns true if the field is searchable.protected final LeafFactory
leafFactory
(SearchExecutionContext context) Create a script leaf factory for queries.protected final LeafFactory
leafFactory
(SearchLookup searchLookup) Create a script leaf factory.org.apache.lucene.search.Query
multiPhraseQuery
(org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements, SearchExecutionContext context) org.apache.lucene.search.Query
phrasePrefixQuery
(org.apache.lucene.analysis.TokenStream stream, int slop, int maxExpansions, SearchExecutionContext context) org.apache.lucene.search.Query
phraseQuery
(org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements, SearchExecutionContext context) org.apache.lucene.search.Query
prefixQuery
(String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) protected abstract org.apache.lucene.search.Query
rangeQuery
(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, ZoneId timeZone, DateMathParser parser, SearchExecutionContext context) final org.apache.lucene.search.Query
rangeQuery
(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, ShapeRelation relation, ZoneId timeZone, DateMathParser parser, SearchExecutionContext context) Factory method for range queries.org.apache.lucene.search.Query
regexpQuery
(String value, int syntaxFlags, int matchFlags, int maxDeterminizedStates, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, SearchExecutionContext context) org.apache.lucene.queries.spans.SpanQuery
spanPrefixQuery
(String value, org.apache.lucene.queries.spans.SpanMultiTermQueryWrapper.SpanRewriteMethod method, SearchExecutionContext context) void
validateMatchedRoutingPath
(String routingPath) Validate that this field can be the target ofIndexMetadata.INDEX_ROUTING_PATH
.valueFetcher
(SearchExecutionContext context, String format) Create a helper class to fetch field values during theFetchFieldsPhase
.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, getMetricType, getTerms, getTextSearchInfo, hasDocValues, isDimension, isFieldWithinQuery, isIndexed, isStored, mayExistInIndex, meta, name, normalizedWildcardQuery, pointReaderIfPossible, prefixIntervals, prefixQuery, termIntervals, termQuery, termQueryCaseInsensitive, termsQuery, typeName, valueForDisplay, wildcardIntervals, wildcardQuery
-
Field Details
-
script
-
DEFAULT_SCRIPT
-
-
Constructor Details
-
AbstractScriptFieldType
protected AbstractScriptFieldType(String name, Function<SearchLookup, LeafFactory> factory, Script script, boolean isResultDeterministic, Map<String, String> meta)
-
-
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
-
rangeQuery
public final org.apache.lucene.search.Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, ShapeRelation relation, ZoneId timeZone, DateMathParser parser, 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
-
rangeQuery
protected abstract org.apache.lucene.search.Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, ZoneId timeZone, DateMathParser parser, SearchExecutionContext context) -
fuzzyQuery
public org.apache.lucene.search.Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions, SearchExecutionContext context, @Nullable org.apache.lucene.search.MultiTermQuery.RewriteMethod rewriteMethod) - Overrides:
fuzzyQuery
in classMappedFieldType
-
prefixQuery
public org.apache.lucene.search.Query prefixQuery(String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) - Overrides:
prefixQuery
in classMappedFieldType
-
wildcardQuery
public org.apache.lucene.search.Query wildcardQuery(String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, boolean caseInsensitive, SearchExecutionContext context) - Overrides:
wildcardQuery
in classMappedFieldType
-
regexpQuery
public org.apache.lucene.search.Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxDeterminizedStates, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, SearchExecutionContext context) - Overrides:
regexpQuery
in classMappedFieldType
-
phraseQuery
public org.apache.lucene.search.Query phraseQuery(org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements, SearchExecutionContext context) - Overrides:
phraseQuery
in classMappedFieldType
-
multiPhraseQuery
public org.apache.lucene.search.Query multiPhraseQuery(org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements, SearchExecutionContext context) - Overrides:
multiPhraseQuery
in classMappedFieldType
-
phrasePrefixQuery
public org.apache.lucene.search.Query phrasePrefixQuery(org.apache.lucene.analysis.TokenStream stream, int slop, int maxExpansions, SearchExecutionContext context) - Overrides:
phrasePrefixQuery
in classMappedFieldType
-
spanPrefixQuery
public org.apache.lucene.queries.spans.SpanQuery spanPrefixQuery(String value, org.apache.lucene.queries.spans.SpanMultiTermQueryWrapper.SpanRewriteMethod method, SearchExecutionContext context) - Overrides:
spanPrefixQuery
in classMappedFieldType
-
applyScriptContext
-
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 throwUnsupportedOperationException
since this could cause a search retrieving multiple fields (like "fields": ["*"]) to fail.- Specified by:
valueFetcher
in classMappedFieldType
-
leafFactory
Create a script leaf factory. -
leafFactory
Create a script leaf factory for queries. -
validateMatchedRoutingPath
Description copied from class:MappedFieldType
Validate that this field can be the target ofIndexMetadata.INDEX_ROUTING_PATH
.- Overrides:
validateMatchedRoutingPath
in classMappedFieldType
-
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
-