Module org.elasticsearch.server
Class ContextMapping<T extends ToXContent>
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMapping<T>
- All Implemented Interfaces:
ToXContent,ToXContentFragment
- Direct Known Subclasses:
CategoryContextMapping,GeoContextMapping
public abstract class ContextMapping<T extends ToXContent>
extends Object
implements 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 final recordstatic enumNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected final Stringprotected final ContextMapping.TypeFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedContextMapping(ContextMapping.Type type, String name) Define a new context mapping of a specific type -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected abstract TfromXContent(XContentParser context) Prototype for the query contextinthashCode()name()parseContext(DocumentParserContext documentParserContext, XContentParser parser) Parses a set of index-time contexts.parseContext(LuceneDocument document) Retrieves a set of context from adocumentat index-time.parseQueryContext(XContentParser parser) Parses query contexts for this mapperprotected abstract XContentBuildertoInnerXContent(XContentBuilder builder, 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 XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params) type()voidvalidateReferences(IndexVersion 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, waitMethods 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.CATEGORYorContextMapping.Type.GEOname- 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, XContentParser parser) throws IOException, ElasticsearchParseException Parses a set of index-time contexts. -
parseContext
Retrieves a set of context from adocumentat index-time. -
fromXContent
Prototype for the query context- Throws:
IOException
-
parseQueryContext
public final List<ContextMapping.InternalQueryContext> parseQueryContext(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 XContentBuilder toInnerXContent(XContentBuilder builder, ToXContent.Params params) throws IOException Implementations should add specific configurations that need to be persisted- Throws:
IOException
-
validateReferences
public void validateReferences(IndexVersion 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 XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-