Class ContextMappings
- java.lang.Object
-
- org.elasticsearch.search.suggest.completion.context.ContextMappings
-
- All Implemented Interfaces:
Iterable<ContextMapping<?>>,ToXContent
public class ContextMappings extends Object implements ToXContent, Iterable<ContextMapping<?>>
ContextMappings indexes context-enabled suggestion fields and creates context queries for definedContextMappings for aCompletionFieldMapper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
-
Field Summary
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description ContextMappings(List<ContextMapping<?>> contextMappings)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddField(ParseContext.Document document, String name, String input, int weight, Map<String,Set<String>> contexts)Adds a context-enabled field for all the defined mappings todocumentseeContextMappings.TypedContextFieldbooleanequals(Object obj)ContextMapping<?>get(String name)Returns a context mapping by its nameMap<String,Set<String>>getNamedContexts(List<CharSequence> contexts)Maps an output context list to a map of context mapping names and their values seeContextMappings.TypedContextFieldinthashCode()Iterator<ContextMapping<?>>iterator()static ContextMappingsload(Object configuration, Version indexVersionCreated)LoadsContextMappingsfrom configuration Expected configuration: List of maps representingContextMapping[{"name": .., "type": .., ..}, {..}]intsize()ContextQuerytoContextQuery(CompletionQuery query, Map<String,List<ContextMapping.InternalQueryContext>> queryContexts)Wraps aCompletionQuerywith context queriesXContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)Writes a list of objects specified by the definedContextMappings seeContextMapping.toXContent(XContentBuilder, Params)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
isFragment
-
-
-
-
Constructor Detail
-
ContextMappings
public ContextMappings(List<ContextMapping<?>> contextMappings)
-
-
Method Detail
-
size
public int size()
- Returns:
- number of context mappings held by this instance
-
get
public ContextMapping<?> get(String name)
Returns a context mapping by its name
-
addField
public void addField(ParseContext.Document document, String name, String input, int weight, Map<String,Set<String>> contexts)
Adds a context-enabled field for all the defined mappings todocumentseeContextMappings.TypedContextField
-
iterator
public Iterator<ContextMapping<?>> iterator()
- Specified by:
iteratorin interfaceIterable<ContextMapping<?>>
-
toContextQuery
public ContextQuery toContextQuery(CompletionQuery query, Map<String,List<ContextMapping.InternalQueryContext>> queryContexts)
Wraps aCompletionQuerywith context queries- Parameters:
query- base completion query to wrapqueryContexts- a map of context mapping name and collected query contexts- Returns:
- a context-enabled query
-
getNamedContexts
public Map<String,Set<String>> getNamedContexts(List<CharSequence> contexts)
Maps an output context list to a map of context mapping names and their values seeContextMappings.TypedContextField- Returns:
- a map of context names and their values
-
load
public static ContextMappings load(Object configuration, Version indexVersionCreated) throws ElasticsearchParseException
LoadsContextMappingsfrom configuration Expected configuration: List of maps representingContextMapping[{"name": .., "type": .., ..}, {..}]- Throws:
ElasticsearchParseException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
Writes a list of objects specified by the definedContextMappings seeContextMapping.toXContent(XContentBuilder, Params)- Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
-