Sha256: 26c454b9f0c0fedd08047968d57bc6190ad61edfd241728f4c3d29dcb200823c
Contents?: true
Size: 813 Bytes
Versions: 8
Compression:
Stored size: 813 Bytes
Contents
module Searchkick class Results < Tire::Results::Collection 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 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 # fixes deprecation warning def __find_records_by_ids(klass, ids) @options[:load] === true ? klass.find(ids) : klass.includes(@options[:load][:include]).find(ids) end end end
Version data entries
8 entries across 8 versions & 1 rubygems