Class: Searchkick::Results
- Inherits:
-
Tire::Results::Collection
- Object
- Tire::Results::Collection
- Searchkick::Results
- Defined in:
- lib/searchkick/results.rb
Instance Method Summary collapse
-
#__find_records_by_ids(klass, ids) ⇒ Object
fixes deprecation warning.
- #suggestions ⇒ Object
- #with_details ⇒ Object
Instance Method Details
#__find_records_by_ids(klass, ids) ⇒ Object
fixes deprecation warning
23 24 25 |
# File 'lib/searchkick/results.rb', line 23 def __find_records_by_ids(klass, ids) @options[:load] === true ? klass.find(ids) : klass.includes(@options[:load][:include]).find(ids) end |
#suggestions ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/searchkick/results.rb', line 4 def suggestions if @response["suggest"] @response["suggest"].values.flat_map{|v| v.first["options"] }.sort_by{|o| -o["score"] }.map{|o| o["text"] }.uniq else raise "Pass `suggest: true` to the search method for suggestions" end end |
#with_details ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/searchkick/results.rb', line 12 def with_details each_with_hit.map do |model, hit| details = {} if hit["highlight"] details[:highlight] = Hash[ hit["highlight"].map{|k, v| [k.sub(/\.analyzed\z/, "").to_sym, v.first] } ] end [model, details] end end |