From 9d2d68775473ecf60acc006f28aace6e8308248b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 17 Mar 2020 22:14:49 -0700 Subject: [PATCH] Added relation option [skip ci] --- lib/searchkick.rb | 5 +++-- test/test_helper.rb | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/searchkick.rb b/lib/searchkick.rb index 80e2516..1995dc5 100644 --- a/lib/searchkick.rb +++ b/lib/searchkick.rb @@ -36,7 +36,7 @@ module Searchkick class ImportError < Error; end class << self - attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name, :model_options + attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name, :model_options, :relation attr_writer :client, :env, :search_timeout attr_reader :aws_credentials end @@ -47,6 +47,7 @@ module Searchkick self.client_options = {} self.queue_name = :searchkick self.model_options = {} + self.relation = false def self.client @client ||= begin @@ -113,7 +114,7 @@ module Searchkick end options = options.merge(block: block) if block - if relation + if relation || (relation.nil? && Searchick.relation) Searchkick::Relation.new(klass, term, **options) else query = Searchkick::Query.new(klass, term, **options) diff --git a/test/test_helper.rb b/test/test_helper.rb index cad70f0..295024d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,6 +14,8 @@ Searchkick.client.transport.logger = $logger Searchkick.search_timeout = 5 Searchkick.index_suffix = ENV["TEST_ENV_NUMBER"] # for parallel tests +Searchkick.relation = ENV["RELATION"] + # add to elasticsearch-7.0.0/config/ Searchkick.wordnet_path = "wn_s.pl" if ENV["WORDNET"] -- libgit2 0.21.0