Class ContextMapping<T extends org.elasticsearch.common.xcontent.ToXContent>

java.lang.Object
org.elasticsearch.search.suggest.completion.context.ContextMapping<T>
All Implemented Interfaces:
org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment
Direct Known Subclasses:
CategoryContextMapping, GeoContextMapping

public abstract class ContextMapping<T extends org.elasticsearch.common.xcontent.ToXContent>
extends java.lang.Object
implements org.elasticsearch.common.xcontent.ToXContentFragment
A ContextMapping defines criteria that can be used to filter and/or boost suggestions at query time for CompletionFieldMapper. Implementations have to define how contexts are parsed at query/index time
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  ContextMapping.InternalQueryContext  
    static class  ContextMapping.Type  

    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
    Modifier and Type Field Description
    static java.lang.String FIELD_NAME  
    static java.lang.String FIELD_TYPE  
    protected java.lang.String name  
    protected ContextMapping.Type type  

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

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected ContextMapping​(ContextMapping.Type type, java.lang.String name)
    Define a new context mapping of a specific type
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object o)  
    protected abstract T fromXContent​(org.elasticsearch.common.xcontent.XContentParser context)
    Prototype for the query context
    int hashCode()  
    java.lang.String name()  
    protected abstract java.util.Set<java.lang.String> parseContext​(ParseContext.Document document)
    Retrieves a set of context from a document at index-time.
    abstract java.util.Set<java.lang.String> parseContext​(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser)
    Parses a set of index-time contexts.
    java.util.List<ContextMapping.InternalQueryContext> parseQueryContext​(org.elasticsearch.common.xcontent.XContentParser parser)
    Parses query contexts for this mapper
    protected abstract org.elasticsearch.common.xcontent.XContentBuilder toInnerXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
    Implementations should add specific configurations that need to be persisted
    protected abstract java.util.List<ContextMapping.InternalQueryContext> toInternalQueryContexts​(java.util.List<T> queryContexts)
    Convert query contexts to common representation
    java.lang.String toString()  
    org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)  
    ContextMapping.Type type()  
    void validateReferences​(Version indexVersionCreated, java.util.function.Function<java.lang.String,​MappedFieldType> fieldResolver)
    Checks if the current context is consistent with the rest of the fields.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

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

    isFragment
  • Field Details

  • Constructor Details

  • Method Details

    • type

      public ContextMapping.Type type()
      Returns:
      the type name of the context
    • name

      public java.lang.String name()
      Returns:
      the name/id of the context
    • parseContext

      public abstract java.util.Set<java.lang.String> parseContext​(ParseContext parseContext, org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException, ElasticsearchParseException
      Parses a set of index-time contexts.
      Throws:
      java.io.IOException
      ElasticsearchParseException
    • parseContext

      protected abstract java.util.Set<java.lang.String> parseContext​(ParseContext.Document document)
      Retrieves a set of context from a document at index-time.
    • fromXContent

      protected abstract T fromXContent​(org.elasticsearch.common.xcontent.XContentParser context) throws java.io.IOException
      Prototype for the query context
      Throws:
      java.io.IOException
    • parseQueryContext

      public final java.util.List<ContextMapping.InternalQueryContext> parseQueryContext​(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException, ElasticsearchParseException
      Parses query contexts for this mapper
      Throws:
      java.io.IOException
      ElasticsearchParseException
    • toInternalQueryContexts

      protected abstract java.util.List<ContextMapping.InternalQueryContext> toInternalQueryContexts​(java.util.List<T> queryContexts)
      Convert query contexts to common representation
    • toInnerXContent

      protected abstract org.elasticsearch.common.xcontent.XContentBuilder toInnerXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Implementations should add specific configurations that need to be persisted
      Throws:
      java.io.IOException
    • validateReferences

      public void validateReferences​(Version indexVersionCreated, java.util.function.Function<java.lang.String,​MappedFieldType> fieldResolver)
      Checks if the current context is consistent with the rest of the fields. For example, the GeoContext should check that the field that it points to has the correct type.
    • toXContent

      public final org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

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

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