class Sunspot::Search::AbstractSearch

Attributes

solr_result[RW]

Public Instance Methods

all_suggestions() click to toggle source
# File lib/sunspot/sunspot_spellcheck.rb, line 63
def all_suggestions
  suggestions.inject([]) { |all, current| all += current }
end
collation() click to toggle source
# File lib/sunspot/sunspot_spellcheck.rb, line 67
def collation
  suggestions.try(:[], 'collation')
end
raw_suggestions() click to toggle source
# File lib/sunspot/sunspot_spellcheck.rb, line 44
def raw_suggestions
  %w(spellcheck suggestions).inject(@solr_result) { |h, k| h && h[k] }
end
suggestions() click to toggle source
# File lib/sunspot/sunspot_spellcheck.rb, line 48
def suggestions
  suggestions = %w(spellcheck suggestions).inject(@solr_result) { |h, k| h && h[k] }
  return nil unless suggestions.is_a?(Array)

  suggestions_hash = {}
  index = -1
  suggestions.each do |sug|
    index += 1
    next unless sug.is_a?(String)
    break unless suggestions.count > index + 1
    suggestions_hash[sug] = suggestions[index + 1].try(:[], 'suggestion') || suggestions[index + 1]
  end
  suggestions_hash
end