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

    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
    Constructor Description
    ContextMappings​(java.util.List<ContextMapping<?>> contextMappings)  
  • Method Summary

    Modifier and Type Method Description
    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 to document see ContextMappings.TypedContextField
    boolean equals​(java.lang.Object obj)  
    ContextMapping<?> get​(java.lang.String name)
    Returns a context mapping by its name
    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 see ContextMappings.TypedContextField
    int hashCode()  
    java.util.Iterator<ContextMapping<?>> iterator()  
    static ContextMappings load​(java.lang.Object configuration)
    Loads ContextMappings from configuration Expected configuration: List of maps representing ContextMapping [{"name": .., "type": .., ..}, {..}]
    int size()  
    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 a CompletionQuery with context queries
    java.lang.String toString()  
    org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
    Writes a list of objects specified by the defined ContextMappings see ContextMapping.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.common.xcontent.ToXContent

    isFragment
  • Constructor Details

    • ContextMappings

      public ContextMappings​(java.util.List<ContextMapping<?>> contextMappings)
  • Method Details

    • size

      public int size()
      Returns:
      number of context mappings held by this instance
    • get

      public ContextMapping<?> get​(java.lang.String name)
      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 to document see ContextMappings.TypedContextField
    • iterator

      public java.util.Iterator<ContextMapping<?>> iterator()
      Specified by:
      iterator in interface java.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 a CompletionQuery with context queries
      Parameters:
      query - base completion query to wrap
      queryContexts - 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 see ContextMappings.TypedContextField
      Returns:
      a map of context names and their values
    • load

      public static ContextMappings load​(java.lang.Object configuration) throws ElasticsearchParseException
      Loads ContextMappings from configuration Expected configuration: List of maps representing ContextMapping [{"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.IOException
      Writes a list of objects specified by the defined ContextMappings see ContextMapping.toXContent(XContentBuilder, Params)
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object