Class FlattenedFieldMapper
java.lang.Object
org.elasticsearch.index.mapper.Mapper
org.elasticsearch.index.mapper.FieldMapper
org.elasticsearch.index.mapper.DynamicKeyFieldMapper
org.elasticsearch.index.mapper.flattened.FlattenedFieldMapper
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<Mapper>
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
public final class FlattenedFieldMapper extends DynamicKeyFieldMapper
A field mapper that accepts a JSON object and flattens it into a single field. This data type
can be a useful alternative to an 'object' mapping when the object has a large, unknown set
of keys.
Currently the mapper extracts all leaf values of the JSON object, converts them to their text
representations, and indexes each one as a keyword. It creates both a 'keyed' version of the token
to allow searches on particular key-value pairs, as well as a 'root' token without the key
As an example, given a flattened field called 'field' and the following input
{
"field": {
"key1": "some value",
"key2": {
"key3": true
}
}
}
the mapper will produce untokenized string fields with the name "field" and values
"some value" and "true", as well as string fields called "field._keyed" with values
"key\0some value" and "key2.key3\0true". Note that \0 is used as a reserved separator
character (see
FlattenedFieldParser.SEPARATOR
).-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FlattenedFieldMapper.Builder
static class
FlattenedFieldMapper.KeyedFlattenedFieldData
A field data implementation that gives access to the values associated with a particular JSON key.static class
FlattenedFieldMapper.KeyedFlattenedFieldType
A field type that represents the values under a particular JSON key, used when searching under a specific key as in 'my_flattened.key: some_value'.static class
FlattenedFieldMapper.RootFlattenedFieldType
A field type that represents all 'root' values.Nested classes/interfaces inherited from class org.elasticsearch.index.mapper.FieldMapper
FieldMapper.Conflicts, FieldMapper.CopyTo, FieldMapper.MergeValidator<T>, FieldMapper.MultiFields, FieldMapper.Parameter<T>, FieldMapper.Serializer<T>, FieldMapper.SerializerCheck<T>, FieldMapper.TypeParser
Nested 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
Fields Modifier and Type Field Description static java.lang.String
CONTENT_TYPE
static FieldMapper.TypeParser
PARSER
Fields inherited from class org.elasticsearch.index.mapper.FieldMapper
COERCE_SETTING, copyTo, hasScript, IGNORE_MALFORMED_SETTING, indexAnalyzers, mappedFieldType, multiFields, onScriptError
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Method Summary
Modifier and Type Method Description protected java.lang.String
contentType()
FlattenedFieldMapper.RootFlattenedFieldType
fieldType()
FieldMapper.Builder
getMergeBuilder()
Returns aFieldMapper.Builder
to be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this);
FlattenedFieldMapper.KeyedFlattenedFieldType
keyedFieldType(java.lang.String key)
protected void
parseCreateField(ParseContext context)
Parse the field value and populate the fields onParseContext.doc()
.Methods inherited from class org.elasticsearch.index.mapper.FieldMapper
checkIncomingMergeType, copyTo, createFieldNamesField, doValidate, doXContentBody, executeScript, hasScript, indexAnalyzers, indexScriptValues, iterator, merge, multiFields, name, parse, parsesArrayValue, toXContent, typeName, validate
Methods inherited from class org.elasticsearch.index.mapper.Mapper
simpleName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
CONTENT_TYPE
public static final java.lang.String CONTENT_TYPE- See Also:
- Constant Field Values
-
PARSER
-
-
Method Details
-
contentType
protected java.lang.String contentType()- Specified by:
contentType
in classFieldMapper
-
fieldType
- Overrides:
fieldType
in classFieldMapper
-
keyedFieldType
- Specified by:
keyedFieldType
in classDynamicKeyFieldMapper
-
parseCreateField
Description copied from class:FieldMapper
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- Specified by:
parseCreateField
in classFieldMapper
- Throws:
java.io.IOException
-
getMergeBuilder
Description copied from class:FieldMapper
Returns aFieldMapper.Builder
to be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this);
- Specified by:
getMergeBuilder
in classFieldMapper
-