Class SuggestField

  • All Implemented Interfaces:
    Direct Known Subclasses:

    public class SuggestField
    extends Field
    Field that indexes a string value and a weight as a weighted completion against a named suggester. Field is tokenized, not stored and stores documents, frequencies and positions. Field can be used to provide near real time document suggestions.

    Besides the usual Analyzers, CompletionAnalyzer can be used to tune suggest field only parameters (e.g. preserving token separators, preserving position increments when converting the token stream to an automaton)

    Example indexing usage:

     document.add(new SuggestField(name, "suggestion", 4));
    To perform document suggestions based on the this field, use SuggestIndexSearcher.suggest(CompletionQuery, int, boolean)
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Field Detail

      • FIELD_TYPE

        public static final FieldType FIELD_TYPE
        Default field type for suggest field
    • Constructor Detail

      • SuggestField

        public SuggestField​(String name,
                            String value,
                            int weight)
        Creates a SuggestField
        name - field name
        value - field value to get suggestions on
        weight - field weight
        IllegalArgumentException - if either the name or value is null, if value is an empty string, if the weight is negative, if value contains any reserved characters