Class ContextMapping<T extends org.elasticsearch.common.xcontent.ToXContent>
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMapping<T>
- All Implemented Interfaces:
org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentFragment
- Direct Known Subclasses:
CategoryContextMapping,GeoContextMapping
public abstract class ContextMapping<T extends org.elasticsearch.common.xcontent.ToXContent>
extends Object
implements org.elasticsearch.common.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 classstatic classNested 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
FieldsModifier and TypeFieldDescriptionstatic Stringstatic Stringprotected Stringprotected ContextMapping.TypeFields inherited from interface org.elasticsearch.common.xcontent.ToXContent
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(org.elasticsearch.common.xcontent.XContentParser context)Prototype for the query contextinthashCode()name()parseContext(LuceneDocument document)Retrieves a set of context from adocumentat index-time.parseContext(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser)Parses a set of index-time contexts.parseQueryContext(org.elasticsearch.common.xcontent.XContentParser parser)Parses query contexts for this mapperprotected abstract org.elasticsearch.common.xcontent.XContentBuildertoInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.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()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)type()voidvalidateReferences(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, waitMethods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
FIELD_TYPE
- See Also:
- Constant Field Values
-
FIELD_NAME
- See Also:
- Constant Field Values
-
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(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser) throws IOException, ElasticsearchParseExceptionParses a set of index-time contexts. -
parseContext
Retrieves a set of context from adocumentat index-time. -
fromXContent
protected abstract T fromXContent(org.elasticsearch.common.xcontent.XContentParser context) throws IOExceptionPrototype for the query context- Throws:
IOException
-
parseQueryContext
public final List<ContextMapping.InternalQueryContext> parseQueryContext(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException, ElasticsearchParseExceptionParses 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.common.xcontent.XContentBuilder toInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOExceptionImplementations 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.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-