Class ContextSuggestField

All Implemented Interfaces:
IndexableField

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:
  document.add(
   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.
  • Field Details

  • Constructor Details

    • ContextSuggestField

      public ContextSuggestField(String name, String value, int weight, CharSequence... contexts)
      Creates a context-enabled suggest field
      Parameters:
      name - field name
      value - field value to get suggestion on
      weight - field weight
      contexts - associated contexts
      Throws:
      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
  • Method Details