Class ContextSuggestField

  • All Implemented Interfaces:

    public class ContextSuggestField
    extends SuggestField
    SuggestField which additionally takes in a set of contexts. Example usage of adding a suggestion with contexts is as follows:
       new ContextSuggestField(name, "suggestion", Arrays.asList("context1", "context2"),  4));
    Use ContextQuery to boost and/or filter suggestions at query-time. Use PrefixCompletionQuery, RegexCompletionQuery or FuzzyCompletionQuery if context boost/filtering are not needed.
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Field Detail


        public static final int CONTEXT_SEPARATOR
        Separator used between context value and the suggest field value
        See Also:
        Constant Field Values
    • Constructor Detail

      • ContextSuggestField

        public ContextSuggestField​(String name,
                                   String value,
                                   int weight,
                                   CharSequence... contexts)
        Creates a context-enabled suggest field
        name - field name
        value - field value to get suggestion on
        weight - field weight
        contexts - associated contexts
        IllegalArgumentException - if either the name or value is null, if value is an empty string, if the weight is negative, if value or contexts contains any reserved characters