Class: Sunspot::Search::AbstractSearch
- Inherits:
-
Object
- Object
- Sunspot::Search::AbstractSearch
- Defined in:
- lib/sunspot/sunspot_spellcheck.rb
Instance Attribute Summary collapse
-
#solr_result ⇒ Object
Returns the value of attribute solr_result.
Instance Method Summary collapse
Instance Attribute Details
#solr_result ⇒ Object
Returns the value of attribute solr_result.
42 43 44 |
# File 'lib/sunspot/sunspot_spellcheck.rb', line 42 def solr_result @solr_result end |
Instance Method Details
#all_suggestions ⇒ Object
63 64 65 |
# File 'lib/sunspot/sunspot_spellcheck.rb', line 63 def all_suggestions suggestions.inject([]) { |all, current| all += current } end |
#collation ⇒ Object
67 68 69 |
# File 'lib/sunspot/sunspot_spellcheck.rb', line 67 def collation suggestions.try(:[], 'collation') end |
#raw_suggestions ⇒ Object
44 45 46 |
# File 'lib/sunspot/sunspot_spellcheck.rb', line 44 def raw_suggestions %w(spellcheck suggestions).inject(@solr_result) { |h, k| h && h[k] } end |
#suggestions ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 |