org.elasticsearch.search.suggest.completion.context.ContextMappings
All Implemented Interfaces:
<ContextMapping<?>>, org.elasticsearch.common.xcontent.ToXContent

public class ContextMappings extends implements org.elasticsearch.common.xcontent.ToXContent, <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
    <ContextMapping<?>> contextMappings)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addField​(LuceneDocument document,  name,  input, int weight, <,​<>> contexts)
    Adds a context-enabled field for all the defined mappings to document see ContextMappings.TypedContextField
    boolean
     obj)
     
     name)
    Returns a context mapping by its name
    <,​<>>
    <> contexts)
    Maps an output context list to a map of context mapping names and their values see ContextMappings.TypedContextField
    int
     
     
     configuration)
    Loads ContextMappings from configuration Expected configuration: List of maps representing ContextMapping [{"name": .., "type": .., ..}, {..}]
    int
     
    org.apache.lucene.search.suggest.document.ContextQuery
    toContextQuery​(org.apache.lucene.search.suggest.document.CompletionQuery query, <,​<ContextMapping.InternalQueryContext>> queryContexts)
    Wraps a CompletionQuery with context queries
     
    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.

    , , , , , , ,

    Methods inherited from interface java.lang.

    ,

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent

    isFragment
  • Constructor Details

    • ContextMappings

      public ContextMappings(<ContextMapping<?>> contextMappings)
  • Method Details

    • size

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

      public  name)
      Returns a context mapping by its name
    • addField

      public void addField(LuceneDocument document,  name,  input, int weight, <,​<>> contexts)
      Adds a context-enabled field for all the defined mappings to document see ContextMappings.TypedContextField
    • iterator

      public <ContextMapping<?>> iterator()
      Specified by:
       in interface <ContextMapping<?>>
    • toContextQuery

      public org.apache.lucene.search.suggest.document.ContextQuery toContextQuery(org.apache.lucene.search.suggest.document.CompletionQuery query, <,​<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 <,​<>> getNamedContexts(<> 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  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
      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:
    • hashCode

      public int hashCode()
      Overrides:
       in class 
    • equals

      public boolean equals( obj)
      Overrides:
       in class 
    • toString

      public  toString()
      Overrides:
       in class