lib/searchkick.rb in searchkick-2.3.1 vs lib/searchkick.rb in searchkick-2.3.2
- old
+ new
@@ -6,10 +6,11 @@
require "searchkick/index"
require "searchkick/indexer"
require "searchkick/reindex_queue"
require "searchkick/results"
require "searchkick/query"
+require "searchkick/multi_search"
require "searchkick/model"
require "searchkick/tasks"
require "searchkick/middleware"
require "searchkick/logging" if defined?(ActiveSupport::Notifications)
require "active_support/core_ext/hash/deep_merge"
@@ -34,11 +35,11 @@
class InvalidQueryError < Elasticsearch::Transport::Transport::Errors::BadRequest; end
class DangerousOperation < Error; end
class ImportError < Error; end
class << self
- attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_suffix, :queue_name
+ attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name
attr_writer :client, :env, :search_timeout
attr_reader :aws_credentials
end
self.search_method_name = :search
self.wordnet_path = "/var/lib/wn_s.pl"
@@ -99,18 +100,12 @@
else
query.execute
end
end
- def self.multi_search(queries)
- if queries.any?
- responses = client.msearch(body: queries.flat_map { |q| [q.params.except(:body), q.body] })["responses"]
- queries.each_with_index do |query, i|
- query.handle_response(responses[i])
- end
- end
- queries
+ def self.multi_search(queries, retry_misspellings: false)
+ Searchkick::MultiSearch.new(queries, retry_misspellings: retry_misspellings).perform
end
# callbacks
def self.enable_callbacks
@@ -151,9 +146,11 @@
batches_left = Searchkick::Index.new(index_name).batches_left
{
completed: batches_left == 0,
batches_left: batches_left
}
+ else
+ raise Searchkick::Error, "Redis not configured"
end
end
def self.with_redis
if redis