Class ContextMappings
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMappings
- All Implemented Interfaces:
Iterable<ContextMapping<?>>,org.elasticsearch.common.xcontent.ToXContent
public class ContextMappings
extends Object
implements org.elasticsearch.common.xcontent.ToXContent, Iterable<ContextMapping<?>>
ContextMappings indexes context-enabled suggestion fields
and creates context queries for defined
ContextMappings
for a CompletionFieldMapper-
Nested Class Summary
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 interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddField(LuceneDocument document, String name, String input, int weight, Map<String,Set<String>> contexts)Adds a context-enabled field for all the defined mappings todocumentseeContextMappings.TypedContextFieldbooleanReturns a context mapping by its namegetNamedContexts(List<CharSequence> contexts)Maps an output context list to a map of context mapping names and their values seeContextMappings.TypedContextFieldinthashCode()iterator()static ContextMappingsLoadsContextMappingsfrom 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, Map<String,List<ContextMapping.InternalQueryContext>> queryContexts)Wraps aCompletionQuerywith context queriestoString()org.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)Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.elasticsearch.common.xcontent.ToXContent
isFragment
-
Constructor Details
-
ContextMappings
-
-
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(LuceneDocument 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
- Specified by:
iteratorin interfaceIterable<ContextMapping<?>>
-
toContextQuery
public org.apache.lucene.search.suggest.document.ContextQuery toContextQuery(org.apache.lucene.search.suggest.document.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
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
LoadsContextMappingsfrom 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 IOExceptionWrites a list of objects specified by the definedContextMappings seeContextMapping.toXContent(XContentBuilder, Params)- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-
toString
-