java.lang.Object
org.elasticsearch.index.mapper.Mapper
org.elasticsearch.index.mapper.FieldMapper
- All Implemented Interfaces:
Cloneable,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 classA Builder for a ParametrizedFieldMapperstatic final classstatic classRepresents a list of fields with optional boost factor where the current field should be copied toprotected static interfacestatic final classstatic final classA configurable parameter for a field mapperstatic interfaceSerializes a parameterstatic interfaceCheck on whether or not a parameter should be serializedstatic final classTypeParser implementation that automatically handles parsingNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FieldMapper.CopyToprotected static final DeprecationLoggerprotected final booleanprotected final MappedFieldTypeprotected final FieldMapper.MultiFieldsprotected final OnScriptErrorFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFieldMapper(String simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo) protectedFieldMapper(String simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, OnScriptError onScriptError) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckIncomingMergeType(FieldMapper mergeWith) protected abstract StringcopyTo()List of fields where this field should be copied toprotected voiddoValidate(MappingLookup mappers) protected voiddoXContentBody(XContentBuilder builder, ToXContent.Params params) final voidexecuteScript(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, DocumentParserContext documentParserContext) Execute the index-time script associated with this field mapper.abstract FieldMapper.BuilderReturns aFieldMapper.Builderto be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this);final booleanbooleanWill 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 voidindexScriptValues(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 returnedtrueiterator()final FieldMappermerge(Mapper mergeWith, MapperBuilderContext mapperBuilderContext) Return the merge ofmergeWithinto this.name()Returns the canonical name which uniquely identifies the mapper against other mappers in a type.static BiConsumer<String,MappingParserContext> notInMultiFields(String type) voidparse(DocumentParserContext context) Parse the field value using the providedDocumentParserContext.protected abstract voidparseCreateField(DocumentParserContext context) Parse the field value and populate the fields onDocumentParserContext.doc().booleanWhether this mapper can handle an array value during document parsing.toXContent(XContentBuilder builder, ToXContent.Params params) typeName()Returns a name representing the type of this mapper.final voidvalidate(MappingLookup mappers) Validate any cross-field references made by this mapperMethods inherited from class org.elasticsearch.index.mapper.Mapper
internFieldName, simpleName, syntheticFieldLoader, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
IGNORE_MALFORMED_SETTING
-
COERCE_SETTING
-
deprecationLogger
-
mappedFieldType
-
multiFields
-
copyTo
-
hasScript
protected final boolean hasScript -
onScriptError
-
-
Constructor Details
-
FieldMapper
protected FieldMapper(String simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo) - Parameters:
simpleName- the leaf name of the mappermappedFieldType- the MappedFieldType associated with this mappermultiFields- sub fields of this mappercopyTo- copyTo fields of this mapper
-
FieldMapper
protected FieldMapper(String simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, OnScriptError onScriptError) - Parameters:
simpleName- the leaf name of the mappermappedFieldType- the MappedFieldType associated with this mappermultiFields- sub fields of this mappercopyTo- copyTo fields of this mapperhasScript- whether a script is defined for the fieldonScriptError- the behaviour for when the defined script fails at runtime
-
-
Method Details
-
name
Description copied from class:MapperReturns the canonical name which uniquely identifies the mapper against other mappers in a type. -
typeName
Description copied from class:MapperReturns a name representing the type of this mapper. -
fieldType
-
copyTo
List of fields where this field should be copied to -
multiFields
-
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 returnfalsehere. -
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. -
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
-
validate
Description copied from class:MapperValidate any cross-field references made by this mapper- Specified by:
validatein classMapper- Parameters:
mappers- aMappingLookupthat can produce references to other mappers
-
doValidate
-
getMergeBuilder
Returns aFieldMapper.Builderto be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this); -
merge
Description copied from class:MapperReturn the merge ofmergeWithinto this. BoththisandmergeWithwill be left unmodified. -
checkIncomingMergeType
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
doXContentBody
- Throws:
IOException
-
contentType
-
indexAnalyzers
-
notInMultiFields
-