Sha256: 80ae2d0d8879a21201ab16ae394bb56d3af6e12cf3d7caf530c35c13ed0f233e

Contents?: true

Size: 533 Bytes

Versions: 13

Compression:

Stored size: 533 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

    # 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

13 entries across 13 versions & 1 rubygems

Version Path
searchkick-0.3.3 lib/searchkick/results.rb
searchkick-0.3.2 lib/searchkick/results.rb
searchkick-0.3.1 lib/searchkick/results.rb
searchkick-0.3.0 lib/searchkick/results.rb
searchkick-0.2.8 lib/searchkick/results.rb
searchkick-0.2.7 lib/searchkick/results.rb
searchkick-0.2.6 lib/searchkick/results.rb
searchkick-0.2.5 lib/searchkick/results.rb
searchkick-0.2.4 lib/searchkick/results.rb
searchkick-0.2.3 lib/searchkick/results.rb
searchkick-0.2.2 lib/searchkick/results.rb
searchkick-0.2.1 lib/searchkick/results.rb
searchkick-0.2.0 lib/searchkick/results.rb