Class SpellingResult


  • public class SpellingResult
    extends Object
    Implementations of SolrSpellChecker must return suggestions as SpellResult instance. This is converted into the required NamedList format in SpellCheckComponent.
    Since:
    solr 1.3
    • Constructor Detail

      • SpellingResult

        public SpellingResult()
    • Method Detail

      • add

        public void add​(Token token,
                        List<String> suggestions)
        Adds a whole bunch of suggestions, and does not worry about frequency.
        Parameters:
        token - The token to associate the suggestions with
        suggestions - The suggestions
      • addFrequency

        public void addFrequency​(Token token,
                                 int docFreq)
        Adds an original token with its document frequency
        Parameters:
        token - original token
        docFreq - original token's document frequency
      • add

        public void add​(Token token,
                        String suggestion,
                        int docFreq)
        Suggestions must be added with the best suggestion first. ORDER is important.
        Parameters:
        token - The Token
        suggestion - The suggestion for the Token
        docFreq - The document frequency
      • get

        public LinkedHashMap<String,​Integer> get​(Token token)
        Gets the suggestions for the given token.
        Parameters:
        token - The Token to look up
        Returns:
        A LinkedHashMap of the suggestions. Key is the suggestion, value is the token frequency in the index, else NO_FREQUENCY_INFO.

        The suggestions are added in sorted order (i.e. best suggestion first) then the iterator will return the suggestions in order

      • getTokenFrequency

        public Integer getTokenFrequency​(Token token)
        The token frequency of the input token in the collection
        Parameters:
        token - The token
        Returns:
        The frequency or null
      • hasTokenFrequencyInfo

        public boolean hasTokenFrequencyInfo()
      • getSuggestions

        public Map<Token,​LinkedHashMap<String,​Integer>> getSuggestions()
        All the suggestions. The ordering of the inner LinkedHashMap is by best suggestion first.
        Returns:
        The Map of suggestions for each Token. Key is the token, value is a LinkedHashMap whose key is the Suggestion and the value is the frequency or NO_FREQUENCY_INFO if frequency info is not available.
      • getTokens

        public Collection<Token> getTokens()
        Returns:
        The original tokens