Commit 36916f445fe94232c40f5ffc9b981fb65ab90370

Authored by Andrew Kane
1 parent 9b11e5b3

Updated search_method_name option

CHANGELOG.md
  1 +## 0.8.1 [unreleased]
  2 +
  3 +- Added `search_method_name` option
  4 +
1 5 ## 0.8.0
2 6  
3 7 - Added support for Elasticsearch 1.2
... ...
README.md
... ... @@ -757,7 +757,7 @@ Product.enable_search_callbacks # or use Searchkick.enable_callbacks for all mod
757 757 Product.reindex
758 758 ```
759 759  
760   -Change the #search method name in `config/initializers/searchkick.rb`
  760 +Change the search method name in `config/initializers/searchkick.rb` [master]
761 761  
762 762 ```ruby
763 763 Searchkick.search_method_name = :lookup
... ...
lib/searchkick.rb
... ... @@ -16,13 +16,10 @@ module Searchkick
16 16 class UnsupportedVersionError < StandardError; end
17 17 class InvalidQueryError < Elasticsearch::Transport::Transport::Errors::BadRequest; end
18 18  
19   - def self.search_method_name=(_search_method_name)
20   - @search_method_name ||= _search_method_name
21   - end
22   -
23   - def self.search_method_name
24   - @search_method_name || :search
  19 + class << self
  20 + attr_accessor :search_method_name
25 21 end
  22 + self.search_method_name = :search
26 23  
27 24 def self.client
28 25 @client ||= Elasticsearch::Client.new(url: ENV["ELASTICSEARCH_URL"])
... ...
lib/searchkick/model.rb
... ... @@ -19,7 +19,7 @@ module Searchkick
19 19 Searchkick::Index.new(index)
20 20 end
21 21  
22   - define_singleton_method(Searchkick.search_method_name) do |term, options={}|
  22 + define_singleton_method(Searchkick.search_method_name) do |term = nil, options={}|
23 23 query = Searchkick::Query.new(self, term, options)
24 24 if options[:execute] == false
25 25 query
... ...