Package org.elasticsearch.index.mapper
Class CompletionFieldMapper
java.lang.Object
org.elasticsearch.index.mapper.Mapper
org.elasticsearch.index.mapper.FieldMapper
org.elasticsearch.index.mapper.CompletionFieldMapper
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<Mapper>
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
public class CompletionFieldMapper extends FieldMapper
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, Version)
for CONTEXTSsee
parse(ParseContext)
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 Classes Modifier and Type Class Description static class
CompletionFieldMapper.Builder
Builder forCompletionFieldMapper
static class
CompletionFieldMapper.CompletionFieldType
static class
CompletionFieldMapper.Defaults
static class
CompletionFieldMapper.Fields
static class
CompletionFieldMapper.TypeParser
Nested classes/interfaces inherited from class org.elasticsearch.index.mapper.FieldMapper
FieldMapper.CopyTo, FieldMapper.MultiFields
Nested classes/interfaces inherited from class org.elasticsearch.index.mapper.Mapper
Mapper.BuilderContext
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<java.lang.String>
ALLOWED_CONTENT_FIELD_NAMES
static java.lang.String
CONTENT_TYPE
Fields inherited from class org.elasticsearch.index.mapper.FieldMapper
COERCE_SETTING, copyTo, defaultFieldType, fieldType, IGNORE_MALFORMED_SETTING, indexCreatedVersion, multiFields
-
Constructor Summary
Constructors Constructor Description CompletionFieldMapper(java.lang.String simpleName, MappedFieldType fieldType, Settings indexSettings, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, int maxInputLength)
-
Method Summary
Modifier and Type Method Description protected java.lang.String
contentType()
protected void
doMerge(Mapper mergeWith)
Merge changes coming frommergeWith
in place.CompletionFieldMapper.CompletionFieldType
fieldType()
void
parse(ParseContext 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(ParseContext.Document, String, String, int, Map)
else adds inputs as aSuggestField
protected void
parseCreateField(ParseContext context, java.util.List<org.apache.lucene.index.IndexableField> fields)
Parse the field value and populatefields
.boolean
parsesArrayValue()
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)
Methods inherited from class org.elasticsearch.index.mapper.FieldMapper
clone, copyTo, createFieldNamesField, doXContentAnalyzers, doXContentBody, doXContentDocValues, indexOptionToString, iterator, merge, name, termVectorOptionsToString, typeName, updateFieldType
-
Field Details
-
CONTENT_TYPE
public static final java.lang.String CONTENT_TYPE- See Also:
- Constant Field Values
-
ALLOWED_CONTENT_FIELD_NAMES
public static final java.util.Set<java.lang.String> ALLOWED_CONTENT_FIELD_NAMES
-
-
Constructor Details
-
CompletionFieldMapper
public CompletionFieldMapper(java.lang.String simpleName, MappedFieldType fieldType, Settings indexSettings, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo, int maxInputLength)
-
-
Method Details
-
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(ParseContext.Document, String, String, int, Map)
else adds inputs as aSuggestField
- Overrides:
parse
in classFieldMapper
- Throws:
java.io.IOException
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Overrides:
toXContent
in classFieldMapper
- Throws:
java.io.IOException
-
parseCreateField
protected void parseCreateField(ParseContext context, java.util.List<org.apache.lucene.index.IndexableField> fields) throws java.io.IOExceptionDescription copied from class:FieldMapper
Parse the field value and populatefields
. 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
-
contentType
protected java.lang.String contentType()- Specified by:
contentType
in classFieldMapper
-
doMerge
Description copied from class:FieldMapper
Merge changes coming frommergeWith
in place.- Overrides:
doMerge
in classFieldMapper
-