Module org.elasticsearch.server
Class ContextMappings
java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMappings
- All Implemented Interfaces:
Iterable<ContextMapping<?>>
,ToXContent
ContextMappings indexes context-enabled suggestion fields
and creates context queries for defined
ContextMapping
s
for a CompletionFieldMapper
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Field Summary
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addField
(LuceneDocument document, String name, String input, int weight, Map<String, Set<String>> contexts) Adds a context-enabled field for all the defined mappings todocument
seeContextMappings.TypedContextField
boolean
Returns 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.TypedContextField
int
hashCode()
iterator()
static ContextMappings
LoadsContextMappings
from configuration Expected configuration: List of maps representingContextMapping
[{"name": .., "type": .., ..}, {..}]int
size()
org.apache.lucene.search.suggest.document.ContextQuery
toContextQuery
(org.apache.lucene.search.suggest.document.CompletionQuery query, Map<String, List<ContextMapping.InternalQueryContext>> queryContexts) Wraps aCompletionQuery
with context queriestoString()
toXContent
(XContentBuilder builder, ToXContent.Params params) Writes a list of objects specified by the definedContextMapping
s seeContextMapping.toXContent(XContentBuilder, Params)
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.elasticsearch.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 todocument
seeContextMappings.TypedContextField
-
iterator
- Specified by:
iterator
in 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 aCompletionQuery
with 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
LoadsContextMappings
from 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 definedContextMapping
s seeContextMapping.toXContent(XContentBuilder, Params)
- Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-
toString
-