java.lang.Object
org.elasticsearch.index.mapper.Mapper
org.elasticsearch.index.mapper.FieldMapper
- All Implemented Interfaces:
Iterable<Mapper>
,ToXContent
,ToXContentFragment
- Direct Known Subclasses:
AbstractGeometryFieldMapper
,BinaryFieldMapper
,BooleanFieldMapper
,CompletionFieldMapper
,DateFieldMapper
,DenseVectorFieldMapper
,FlattenedFieldMapper
,IpFieldMapper
,KeywordFieldMapper
,MetadataFieldMapper
,NumberFieldMapper
,PlaceHolderFieldMapper
,RangeFieldMapper
,SparseVectorFieldMapper
,TextFieldMapper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A Builder for a ParametrizedFieldMapperprotected static final record
static final class
static class
Represents a list of fields with optional boost factor where the current field should be copied tostatic class
Creates mappers for fields that can act as time-series dimensions.protected static interface
static final class
static final class
A configurable parameter for a field mapperstatic interface
Serializes a parameterstatic interface
Check on whether or not a parameter should be serializedprotected static enum
Specifies the mode of synthetic source support by the mapper.protected static interface
Interface that defines how a field supports synthetic source.static final class
TypeParser implementation that automatically handles parsingNested classes/interfaces inherited from class org.elasticsearch.index.mapper.Mapper
Mapper.SourceKeepMode
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FieldMapper.BuilderParams
protected static final DeprecationLogger
protected final MappedFieldType
Fields inherited from class org.elasticsearch.index.mapper.Mapper
SYNTHETIC_SOURCE_KEEP_INDEX_SETTING, SYNTHETIC_SOURCE_KEEP_PARAM
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
FieldMapper
(String simpleName, MappedFieldType mappedFieldType, FieldMapper.BuilderParams params) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkIncomingMergeType
(FieldMapper mergeWith) protected abstract String
copyTo()
List of fields where this field should be copied tostatic FieldMapper.TypeParser
createTypeParserWithLegacySupport
(BiFunction<String, MappingParserContext, FieldMapper.Builder> builderFunction) protected void
doValidate
(MappingLookup mappers) protected void
doXContentBody
(XContentBuilder builder, ToXContent.Params params) final void
executeScript
(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, DocumentParserContext documentParserContext) Execute the index-time script associated with this field mapper.fullPath()
Returns the canonical name which uniquely identifies the mapper against other mappers in a type.abstract FieldMapper.Builder
Returns aFieldMapper.Builder
to be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this);
int
The total number of fields as defined in the mapping.final boolean
boolean
Will this field ignore malformed values for this field and accept the document (true
) or will it reject documents with malformed values for this field (false
).protected void
indexScriptValues
(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, DocumentParserContext documentParserContext) Run the script associated with the field and index the values that it emits This method should only be called ifhasScript()
has returnedtrue
iterator()
final FieldMapper
merge
(Mapper mergeWith, MapperMergeContext mapperMergeContext) Return the merge ofmergeWith
into this.static BiConsumer
<String, MappingParserContext> static BiConsumer
<String, MappingParserContext> notInMultiFields
(String type) void
parse
(DocumentParserContext context) Parse the field value using the providedDocumentParserContext
.protected abstract void
parseCreateField
(DocumentParserContext context) Parse the field value and populate the fields onDocumentParserContext.doc()
.boolean
Whether this mapper can handle an array value during document parsing.protected boolean
Whether this mapper can handle an object value during document parsing.Returns synthetic field loader for the mapper.protected FieldMapper.SyntheticSourceSupport
Returns implementation of synthetic source support for the mapper.toXContent
(XContentBuilder builder, ToXContent.Params params) typeName()
Returns a name representing the type of this mapper.final void
validate
(MappingLookup mappers) Validate any cross-field references made by this mapperMethods inherited from class org.elasticsearch.index.mapper.Mapper
freezeAndDeduplicateFieldType, internFieldName, leafName, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
IGNORE_MALFORMED_SETTING
-
COERCE_SETTING
-
deprecationLogger
-
mappedFieldType
-
builderParams
-
-
Constructor Details
-
FieldMapper
protected FieldMapper(String simpleName, MappedFieldType mappedFieldType, FieldMapper.BuilderParams params) - Parameters:
simpleName
- the leaf name of the mapperparams
- initialization params for this field mapper
-
-
Method Details
-
fullPath
Description copied from class:Mapper
Returns the canonical name which uniquely identifies the mapper against other mappers in a type. -
typeName
Description copied from class:Mapper
Returns a name representing the type of this mapper. -
fieldType
-
copyTo
List of fields where this field should be copied to -
multiFields
-
sourceKeepMode
-
ignoreMalformed
public boolean ignoreMalformed()Will this field ignore malformed values for this field and accept the document (true
) or will it reject documents with malformed values for this field (false
). Some fields don't have a concept of "malformed" and will returnfalse
here. -
parsesArrayValue
public boolean parsesArrayValue()Whether this mapper can handle an array value during document parsing. If true, when an array is encountered during parsing, the document parser will pass the whole array to the mapper. If false, the array is split into individual values and each value is passed to the mapper for parsing. -
supportsParsingObject
protected boolean supportsParsingObject()Whether this mapper can handle an object value during document parsing. When the subobjects property is set to false, and we encounter an object while parsing we need a way to understand if its fieldMapper is able to parse an object. If that's the case we can provide the entire object to the FieldMapper otherwise its name becomes the part of the dotted field name of each internal value. -
parse
Parse the field value using the providedDocumentParserContext
.- Throws:
IOException
-
parseCreateField
Parse the field value and populate the fields onDocumentParserContext.doc()
. Implementations of this method should ensure that on failing to parse parser.currentToken() must be the current failing token- Throws:
IOException
-
hasScript
public final boolean hasScript()- Returns:
- whether this field mapper uses a script to generate its values
-
executeScript
public final void executeScript(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, DocumentParserContext documentParserContext) Execute the index-time script associated with this field mapper. This method should only be called ifhasScript()
has returnedtrue
- Parameters:
searchLookup
- a SearchLookup to be passed the scriptreaderContext
- a LeafReaderContext exposing values from an incoming documentdoc
- the id of the document to execute the script againstdocumentParserContext
- the ParseContext over the incoming document
-
indexScriptValues
protected void indexScriptValues(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, DocumentParserContext documentParserContext) Run the script associated with the field and index the values that it emits This method should only be called ifhasScript()
has returnedtrue
- Parameters:
searchLookup
- a SearchLookup to be passed the scriptreaderContext
- a LeafReaderContext exposing values from an incoming documentdoc
- the id of the document to execute the script againstdocumentParserContext
- the ParseContext over the incoming document
-
iterator
-
multiFieldsIterator
-
sourcePathUsedBy
- Returns:
- a mapper iterator of all fields that use this field's source path as their source path
-
validate
Description copied from class:Mapper
Validate any cross-field references made by this mapper- Specified by:
validate
in classMapper
- Parameters:
mappers
- aMappingLookup
that can produce references to other mappers
-
doValidate
-
getMergeBuilder
Returns aFieldMapper.Builder
to be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this);
-
merge
Description copied from class:Mapper
Return the merge ofmergeWith
into this. Boththis
andmergeWith
will be left unmodified. -
checkIncomingMergeType
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Throws:
IOException
-
doXContentBody
- Throws:
IOException
-
contentType
-
getTotalFieldsCount
public int getTotalFieldsCount()Description copied from class:Mapper
The total number of fields as defined in the mapping. Defines how this mapper counts towardsMapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING
.- Specified by:
getTotalFieldsCount
in classMapper
-
indexAnalyzers
-
syntheticFieldLoader
Returns synthetic field loader for the mapper. If mapper does not support synthetic source, it is handled using generic implementation inDocumentParser.parseObjectOrField(org.elasticsearch.index.mapper.DocumentParserContext, org.elasticsearch.index.mapper.Mapper)
andObjectMapper.syntheticFieldLoader(SourceFilter)
.
This method is final in order to support common use cases like fallback synthetic source. Mappers that need custom support of synthetic source should overridesyntheticSourceSupport()
.- Returns:
- implementation of
SourceLoader.SyntheticFieldLoader
-
syntheticSourceSupport
Returns implementation of synthetic source support for the mapper.
By default (meaningFieldMapper.SyntheticSourceSupport.Fallback
), an exact full copy of parsed field value is stored separately and used for synthetic source.Field mappers must override this method if they provide a more efficient field-specific implementation of synthetic source.
- Returns:
FieldMapper.SyntheticSourceMode
-
notInMultiFields
-
notFromDynamicTemplates
-
createTypeParserWithLegacySupport
public static FieldMapper.TypeParser createTypeParserWithLegacySupport(BiFunction<String, MappingParserContext, FieldMapper.Builder> builderFunction)
-