Class ContextMappings
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMappings
- All Implemented Interfaces:
java.lang.Iterable<ContextMapping<?>>,org.elasticsearch.common.xcontent.ToXContent
public class ContextMappings extends java.lang.Object implements org.elasticsearch.common.xcontent.ToXContent, java.lang.Iterable<ContextMapping<?>>
ContextMappings indexes context-enabled suggestion fields
and creates context queries for defined
ContextMappings
for a CompletionFieldMapper-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ContextMappings(java.util.List<ContextMapping<?>> contextMappings) -
Method Summary
Modifier and Type Method Description voidaddField(ParseContext.Document document, java.lang.String name, java.lang.String input, int weight, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> contexts)Adds a context-enabled field for all the defined mappings todocumentseeContextMappings.TypedContextFieldbooleanequals(java.lang.Object obj)ContextMapping<?>get(java.lang.String name)Returns a context mapping by its namejava.util.Map<java.lang.String,java.util.Set<java.lang.String>>getNamedContexts(java.util.List<java.lang.CharSequence> contexts)Maps an output context list to a map of context mapping names and their values seeContextMappings.TypedContextFieldinthashCode()java.util.Iterator<ContextMapping<?>>iterator()static ContextMappingsload(java.lang.Object configuration, Version indexVersionCreated)LoadsContextMappingsfrom configuration Expected configuration: List of maps representingContextMapping[{"name": .., "type": .., ..}, {..}]intsize()org.apache.lucene.search.suggest.document.ContextQuerytoContextQuery(org.apache.lucene.search.suggest.document.CompletionQuery query, java.util.Map<java.lang.String,java.util.List<ContextMapping.InternalQueryContext>> queryContexts)Wraps aCompletionQuerywith context queriesorg.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)Writes a list of objects specified by the definedContextMappings seeContextMapping.toXContent(XContentBuilder, Params)
-
Constructor Details
-
Method Details
-
size
public int size()- Returns:
- number of context mappings held by this instance
-
get
Returns a context mapping by its name -
addField
public void addField(ParseContext.Document document, java.lang.String name, java.lang.String input, int weight, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> contexts)Adds a context-enabled field for all the defined mappings todocumentseeContextMappings.TypedContextField -
iterator
- Specified by:
iteratorin interfacejava.lang.Iterable<ContextMapping<?>>
-
toContextQuery
public org.apache.lucene.search.suggest.document.ContextQuery toContextQuery(org.apache.lucene.search.suggest.document.CompletionQuery query, java.util.Map<java.lang.String,java.util.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 java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getNamedContexts(java.util.List<java.lang.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(java.lang.Object configuration, Version indexVersionCreated) throws ElasticsearchParseExceptionLoadsContextMappingsfrom configuration Expected configuration: List of maps representingContextMapping[{"name": .., "type": .., ..}, {..}]- Throws:
ElasticsearchParseException
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOExceptionWrites a list of objects specified by the definedContextMappings seeContextMapping.toXContent(XContentBuilder, Params)- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-