Class CategoryContextMapping
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMapping<CategoryQueryContext>
org.elasticsearch.search.suggest.completion.context.CategoryContextMapping
- All Implemented Interfaces:
org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
A
ContextMapping
that uses a simple string as a criteria
The suggestions are boosted and/or filtered by their associated
category (string) value.
CategoryQueryContext
defines options for constructing
a unit of query context for this context type-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
ContextMapping.InternalQueryContext, ContextMapping.Type
Nested 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
Fields inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
FIELD_NAME, FIELD_TYPE, name, type
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Method Summary
Modifier and TypeMethodDescriptionboolean
protected CategoryQueryContext
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Prototype for the query contextName of the field to get contexts from at index-timeint
hashCode()
protected static CategoryContextMapping
Loads aname
dCategoryContextMapping
instance from a map.parseContext(LuceneDocument document)
Retrieves a set of context from adocument
at index-time.parseContext(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser)
Parse a set ofCharSequence
contexts at index-time.protected org.elasticsearch.common.xcontent.XContentBuilder
toInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
Implementations should add specific configurations that need to be persistedtoInternalQueryContexts(List<CategoryQueryContext> queryContexts)
Parse a list ofCategoryQueryContext
usingparser
.Methods inherited from class org.elasticsearch.search.suggest.completion.context.ContextMapping
name, parseQueryContext, toString, toXContent, type, validateReferences
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Method Details
-
getFieldName
Name of the field to get contexts from at index-time -
load
protected static CategoryContextMapping load(String name, Map<String,Object> config) throws ElasticsearchParseExceptionLoads aname
dCategoryContextMapping
instance from a map. seeContextMappings.load(Object)
Acceptable map param:path
- Throws:
ElasticsearchParseException
-
toInnerXContent
protected org.elasticsearch.common.xcontent.XContentBuilder toInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOExceptionDescription copied from class:ContextMapping
Implementations should add specific configurations that need to be persisted- Specified by:
toInnerXContent
in classContextMapping<CategoryQueryContext>
- Throws:
IOException
-
parseContext
public Set<String> parseContext(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser) throws IOException, ElasticsearchParseExceptionParse a set ofCharSequence
contexts at index-time. Acceptable formats:- Array:
[<string>, ..]
- String:
"string"
- Specified by:
parseContext
in classContextMapping<CategoryQueryContext>
- Throws:
IOException
ElasticsearchParseException
- Array:
-
parseContext
Description copied from class:ContextMapping
Retrieves a set of context from adocument
at index-time.- Specified by:
parseContext
in classContextMapping<CategoryQueryContext>
-
fromXContent
protected CategoryQueryContext fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOExceptionDescription copied from class:ContextMapping
Prototype for the query context- Specified by:
fromXContent
in classContextMapping<CategoryQueryContext>
- Throws:
IOException
-
toInternalQueryContexts
public List<ContextMapping.InternalQueryContext> toInternalQueryContexts(List<CategoryQueryContext> queryContexts)Parse a list ofCategoryQueryContext
usingparser
. A QueryContexts accepts one of the following forms:- Object: CategoryQueryContext
- String: CategoryQueryContext value with prefix=false and boost=1
- Array:
[CategoryQueryContext, ..]
- Object:
{"context": <string>, "boost": <int>, "prefix": <boolean>}
- String:
"string"
- Specified by:
toInternalQueryContexts
in classContextMapping<CategoryQueryContext>
-
equals
- Overrides:
equals
in classContextMapping<CategoryQueryContext>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classContextMapping<CategoryQueryContext>
-