Class ContextQuery


  • public class ContextQuery
    extends CompletionQuery
    A CompletionQuery that matches documents specified by a wrapped CompletionQuery supporting boosting and/or filtering by specified contexts.

    Use this query against ContextSuggestField

    Example of using a CompletionQuery with boosted contexts:

      CompletionQuery completionQuery = ...;
      ContextQuery query = new ContextQuery(completionQuery);
      query.addContext("context1", 2);
      query.addContext("context2", 1);
     

    NOTE:

    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Field Detail

    • Method Detail

      • addContext

        public void addContext​(CharSequence context)
        Adds an exact context with default boost of 1
      • addContext

        public void addContext​(CharSequence context,
                               float boost)
        Adds an exact context with boost
      • addContext

        public void addContext​(CharSequence context,
                               float boost,
                               boolean exact)
        Adds a context with boost, set exact to false if the context is a prefix of any indexed contexts
      • addAllContexts

        public void addAllContexts()
        Add all contexts with a boost of 1f
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in class Query