Commit f05a205a09b1865fbcf9b288e41c4679e658cf73

Authored by Andrew
1 parent 8c42f617

Make Searchkick.search(index_name: [Product]) and Product.search equivalent [skip ci]

Showing 1 changed file with 7 additions and 7 deletions   Show diff stats
lib/searchkick.rb
... ... @@ -83,13 +83,13 @@ module Searchkick
83 83 def self.search(term = "*", **options, &block)
84 84 klass = options[:model]
85 85  
86   - # TODO add in next major version
87   - # if !klass
88   - # index_name = Array(options[:index_name])
89   - # if index_name.size == 1 && index_name.first.respond_to?(:searchkick_index)
90   - # klass = index_name.first
91   - # end
92   - # end
  86 + # make Searchkick.search(index_name: [Product]) and Product.search equivalent
  87 + if !klass
  88 + index_name = Array(options[:index_name])
  89 + if index_name.size == 1 && index_name.first.respond_to?(:searchkick_index)
  90 + klass = index_name.first
  91 + end
  92 + end
93 93  
94 94 query = Searchkick::Query.new(klass, term, options.except(:model))
95 95 block.call(query.body) if block
... ...