java.lang.Object
org.elasticsearch.index.mapper.Mapper
org.elasticsearch.index.mapper.FieldMapper
org.elasticsearch.index.mapper.CompletionFieldMapper
- All Implemented Interfaces:
Cloneable
,Iterable<Mapper>
,ToXContent
,ToXContentFragment
Mapper for completion field. The field values are indexed as a weighted FST for
fast auto-completion/search-as-you-type functionality.
Type properties:
see
Type properties:
- "analyzer": "simple", (default)
- "search_analyzer": "simple", (default)
- "preserve_separators" : true, (default)
- "preserve_position_increments" : true (default)
- "min_input_length": 50 (default)
- "contexts" : CONTEXTS
ContextMappings.load(Object)
for CONTEXTSsee
parse(DocumentParserContext)
for acceptable inputs for indexing
This field type constructs completion queries that are run
against the weighted FST index by the CompletionSuggester
.
This field can also be extended to add search criteria to suggestions
for query-time filtering and boosting (see ContextMappings
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder forCompletionFieldMapper
static final class
static class
static class
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.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Field Summary
FieldsFields inherited from class org.elasticsearch.index.mapper.FieldMapper
COERCE_SETTING, copyTo, deprecationLogger, hasScript, IGNORE_MALFORMED_SETTING, mappedFieldType, multiFields, onScriptError
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionCompletionFieldMapper
(String simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, CompletionFieldMapper.Builder builder) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
void
doValidate
(MappingLookup mappers) Returns aFieldMapper.Builder
to be used for merging and serialization Implement as follows:return new MyBuilder(simpleName()).init(this);
void
parse
(DocumentParserContext context) Parses and indexes inputs Parsing: Acceptable format: "STRING" - interpreted as field value (input) "ARRAY" - each element can be one of "OBJECT" (see below) "OBJECT" - { "input": STRING|ARRAY, "weight": STRING|INT, "contexts": ARRAY|OBJECT } Indexing: if context mappings are defined, delegates toContextMappings.addField(LuceneDocument, String, String, int, Map)
else adds inputs as aSuggestField
protected 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.Methods inherited from class org.elasticsearch.index.mapper.FieldMapper
checkIncomingMergeType, copyTo, doXContentBody, executeScript, hasScript, ignoreMalformed, indexScriptValues, iterator, merge, multiFields, name, notInMultiFields, toXContent, typeName, validate
Methods inherited from class org.elasticsearch.index.mapper.Mapper
internFieldName, simpleName, syntheticFieldLoader, 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
-
CONTENT_TYPE
- See Also:
-
ALLOWED_CONTENT_FIELD_NAMES
-
PARSER
-
-
Constructor Details
-
CompletionFieldMapper
public CompletionFieldMapper(String simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, CompletionFieldMapper.Builder builder)
-
-
Method Details
-
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
-
indexAnalyzers
- Overrides:
indexAnalyzers
in classFieldMapper
-
fieldType
- Overrides:
fieldType
in classFieldMapper
-
parsesArrayValue
public boolean parsesArrayValue()Description copied from class:FieldMapper
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.- Overrides:
parsesArrayValue
in classFieldMapper
-
parse
Parses and indexes inputs Parsing: Acceptable format: "STRING" - interpreted as field value (input) "ARRAY" - each element can be one of "OBJECT" (see below) "OBJECT" - { "input": STRING|ARRAY, "weight": STRING|INT, "contexts": ARRAY|OBJECT } Indexing: if context mappings are defined, delegates toContextMappings.addField(LuceneDocument, String, String, int, Map)
else adds inputs as aSuggestField
- Overrides:
parse
in classFieldMapper
- Throws:
IOException
-
parseCreateField
Description copied from class:FieldMapper
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- Specified by:
parseCreateField
in classFieldMapper
- Throws:
IOException
-
contentType
- Specified by:
contentType
in classFieldMapper
-
doValidate
- Overrides:
doValidate
in classFieldMapper
-