Package org.elasticsearch.index.mapper
Class FieldMapper
org.elasticsearch.index.mapper.Mapper
org.elasticsearch.index.mapper.FieldMapper
- All Implemented Interfaces:
,
<Mapper>
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
- Direct Known Subclasses:
AbstractGeometryFieldMapper
,BinaryFieldMapper
,BooleanFieldMapper
,CompletionFieldMapper
,DateFieldMapper
,FlattenedFieldMapper
,IpFieldMapper
,KeywordFieldMapper
,MetadataFieldMapper
,NumberFieldMapper
,RangeFieldMapper
,TextFieldMapper
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A Builder for a ParametrizedFieldMapperstatic class
static class
Represents a list of fields with optional boost factor where the current field should be copied toprotected static interface
static class
static class
A configurable parameter for a field mapperstatic interface
Serializes a parameterstatic interface
Check on whether or not a parameter should be serializedstatic class
TypeParser implementation that automatically handles parsingNested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
-
Field Summary
Modifier and TypeFieldDescriptionstatic >
protected FieldMapper.CopyTo
protected boolean
static >
protected <,NamedAnalyzer>
protected MappedFieldType
protected FieldMapper.MultiFields
protected
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionprotected
simpleName, MappedFieldType mappedFieldType, <,NamedAnalyzer> indexAnalyzers, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, onScriptError)
Create a FieldMapper that indexes into multiple analyzed fieldsprotected
simpleName, MappedFieldType mappedFieldType, NamedAnalyzer indexAnalyzer, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo)
Create a FieldMapper with a single associated index analyzerprotected
simpleName, MappedFieldType mappedFieldType, NamedAnalyzer indexAnalyzer, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, onScriptError)
Create a FieldMapper with a single associated index analyzerprotected
simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo)
Create a FieldMapper with no index analyzersprotected
simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, onScriptError)
Create a FieldMapper with no index analyzers -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkIncomingMergeType(FieldMapper mergeWith)
protected abstract
copyTo()
List of fields where this field should be copied toprotected void
doValidate(MappingLookup mappers)
protected void
doXContentBody(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
executeScript(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, ParseContext parseContext)
Execute the index-time script associated with this field mapper.abstract FieldMapper.Builder
Returns aFieldMapper.Builder
to be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this);
boolean
<,NamedAnalyzer>
protected void
indexScriptValues(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, ParseContext parseContext)
Run the script associated with the field and index the values that it emits This method should only be called ifhasScript()
has returnedtrue
<Mapper>
iterator()
Return the merge ofmergeWith
into this.name()
Returns the canonical name which uniquely identifies the mapper against other mappers in a type.static <,MappingParserContext>
type)
void
parse(ParseContext context)
Parse the field value using the providedParseContext
.protected abstract void
parseCreateField(ParseContext context)
Parse the field value and populate the fields onParseContext.doc()
.boolean
Whether this mapper can handle an array value during document parsing.org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
typeName()
Returns a name representing the type of this mapper.void
validate(MappingLookup mappers)
Validate any cross-field references made by this mapperMethods inherited from class org.elasticsearch.index.mapper.Mapper
simpleName
Methods inherited from class java.lang.
, , , , , , , , , ,
Methods inherited from interface java.lang.
,
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
IGNORE_MALFORMED_SETTING
public static final > IGNORE_MALFORMED_SETTING -
COERCE_SETTING
public static final > COERCE_SETTING -
mappedFieldType
-
indexAnalyzers
-
multiFields
-
copyTo
-
hasScript
protected final boolean hasScript -
onScriptError
protected final onScriptError
-
-
Constructor Details
-
FieldMapper
protected FieldMapper( simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo)Create a FieldMapper with no index analyzers- 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( simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, onScriptError)Create a FieldMapper with no index analyzers- 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
-
FieldMapper
protected FieldMapper( simpleName, MappedFieldType mappedFieldType, NamedAnalyzer indexAnalyzer, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo)Create a FieldMapper with a single associated index analyzer- Parameters:
simpleName
- the leaf name of the mappermappedFieldType
- the MappedFieldType associated with this mapperindexAnalyzer
- the index-time analyzer to use for this fieldmultiFields
- sub fields of this mappercopyTo
- copyTo fields of this mapper
-
FieldMapper
protected FieldMapper( simpleName, MappedFieldType mappedFieldType, NamedAnalyzer indexAnalyzer, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, onScriptError)Create a FieldMapper with a single associated index analyzer- Parameters:
simpleName
- the leaf name of the mappermappedFieldType
- the MappedFieldType associated with this mapperindexAnalyzer
- the index-time analyzer to use for this fieldmultiFields
- 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
-
FieldMapper
protected FieldMapper( simpleName, MappedFieldType mappedFieldType, <,NamedAnalyzer> indexAnalyzers, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, boolean hasScript, onScriptError)Create a FieldMapper that indexes into multiple analyzed fields- Parameters:
simpleName
- the leaf name of the mappermappedFieldType
- the MappedFieldType associated with this mapperindexAnalyzers
- a map of field names to analyzers, one for each analyzed field the mapper will addmultiFields
- 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
public name()Description copied from class:Mapper
Returns the canonical name which uniquely identifies the mapper against other mappers in a type. -
typeName
public 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
-
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 providedParseContext
.- Throws:
-
parseCreateField
Parse the field value and populate the fields onParseContext.doc()
. Implementations of this method should ensure that on failing to parse parser.currentToken() must be the current failing token- Throws:
-
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, ParseContext parseContext)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 againstparseContext
- the ParseContext over the incoming document
-
indexScriptValues
protected void indexScriptValues(SearchLookup searchLookup, org.apache.lucene.index.LeafReaderContext readerContext, int doc, ParseContext parseContext)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 againstparseContext
- the ParseContext over the incoming document
-
iterator
- Specified by:
in interface
<Mapper>
-
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 org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
-
doXContentBody
protected void doXContentBody(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws- Throws:
-
contentType
protected abstract contentType() -
indexAnalyzers
-
notInMultiFields
public static <, type)
-