Class ContextMapping<T extends org.elasticsearch.xcontent.ToXContent>
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMapping<T>
- All Implemented Interfaces:
org.elasticsearch.xcontent.ToXContent
,org.elasticsearch.xcontent.ToXContentFragment
- Direct Known Subclasses:
CategoryContextMapping
,GeoContextMapping
public abstract class ContextMapping<T extends org.elasticsearch.xcontent.ToXContent>
extends Object
implements org.elasticsearch.xcontent.ToXContentFragment
A
ContextMapping
defines criteria that can be used to
filter and/or boost suggestions at query time for CompletionFieldMapper
.
Implementations have to define how contexts are parsed at query/index time-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.Params
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
protected final String
protected final ContextMapping.Type
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ContextMapping
(ContextMapping.Type type, String name) Define a new context mapping of a specific type -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected abstract T
fromXContent
(org.elasticsearch.xcontent.XContentParser context) Prototype for the query contextint
hashCode()
name()
parseContext
(DocumentParserContext documentParserContext, org.elasticsearch.xcontent.XContentParser parser) Parses a set of index-time contexts.parseContext
(LuceneDocument document) Retrieves a set of context from adocument
at index-time.parseQueryContext
(org.elasticsearch.xcontent.XContentParser parser) Parses query contexts for this mapperprotected abstract org.elasticsearch.xcontent.XContentBuilder
toInnerXContent
(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) Implementations should add specific configurations that need to be persistedprotected abstract List<ContextMapping.InternalQueryContext>
toInternalQueryContexts
(List<T> queryContexts) Convert query contexts to common representationtoString()
final org.elasticsearch.xcontent.XContentBuilder
toXContent
(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) type()
void
validateReferences
(Version indexVersionCreated, Function<String, MappedFieldType> fieldResolver) Checks if the current context is consistent with the rest of the fields.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
FIELD_TYPE
- See Also:
-
FIELD_NAME
- See Also:
-
type
-
name
-
-
Constructor Details
-
ContextMapping
Define a new context mapping of a specific type- Parameters:
type
- type of context mapping, eitherContextMapping.Type.CATEGORY
orContextMapping.Type.GEO
name
- name of context mapping
-
-
Method Details
-
type
- Returns:
- the type name of the context
-
name
- Returns:
- the name/id of the context
-
parseContext
public abstract Set<String> parseContext(DocumentParserContext documentParserContext, org.elasticsearch.xcontent.XContentParser parser) throws IOException, ElasticsearchParseException Parses a set of index-time contexts. -
parseContext
Retrieves a set of context from adocument
at index-time. -
fromXContent
protected abstract T fromXContent(org.elasticsearch.xcontent.XContentParser context) throws IOException Prototype for the query context- Throws:
IOException
-
parseQueryContext
public final List<ContextMapping.InternalQueryContext> parseQueryContext(org.elasticsearch.xcontent.XContentParser parser) throws IOException, ElasticsearchParseException Parses query contexts for this mapper -
toInternalQueryContexts
protected abstract List<ContextMapping.InternalQueryContext> toInternalQueryContexts(List<T> queryContexts) Convert query contexts to common representation -
toInnerXContent
protected abstract org.elasticsearch.xcontent.XContentBuilder toInnerXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException Implementations should add specific configurations that need to be persisted- Throws:
IOException
-
validateReferences
public void validateReferences(Version indexVersionCreated, Function<String, MappedFieldType> fieldResolver) Checks if the current context is consistent with the rest of the fields. For example, the GeoContext should check that the field that it points to has the correct type. -
toXContent
public final org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceorg.elasticsearch.xcontent.ToXContent
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-