Commit 9d2d68775473ecf60acc006f28aace6e8308248b
1 parent
3de51462
Exists in
relation
and in
1 other branch
Added relation option [skip ci]
Showing
2 changed files
with
5 additions
and
2 deletions
Show diff stats
lib/searchkick.rb
... | ... | @@ -36,7 +36,7 @@ module Searchkick |
36 | 36 | class ImportError < Error; end |
37 | 37 | |
38 | 38 | class << self |
39 | - attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name, :model_options | |
39 | + attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name, :model_options, :relation | |
40 | 40 | attr_writer :client, :env, :search_timeout |
41 | 41 | attr_reader :aws_credentials |
42 | 42 | end |
... | ... | @@ -47,6 +47,7 @@ module Searchkick |
47 | 47 | self.client_options = {} |
48 | 48 | self.queue_name = :searchkick |
49 | 49 | self.model_options = {} |
50 | + self.relation = false | |
50 | 51 | |
51 | 52 | def self.client |
52 | 53 | @client ||= begin |
... | ... | @@ -113,7 +114,7 @@ module Searchkick |
113 | 114 | end |
114 | 115 | |
115 | 116 | options = options.merge(block: block) if block |
116 | - if relation | |
117 | + if relation || (relation.nil? && Searchick.relation) | |
117 | 118 | Searchkick::Relation.new(klass, term, **options) |
118 | 119 | else |
119 | 120 | query = Searchkick::Query.new(klass, term, **options) | ... | ... |
test/test_helper.rb
... | ... | @@ -14,6 +14,8 @@ Searchkick.client.transport.logger = $logger |
14 | 14 | Searchkick.search_timeout = 5 |
15 | 15 | Searchkick.index_suffix = ENV["TEST_ENV_NUMBER"] # for parallel tests |
16 | 16 | |
17 | +Searchkick.relation = ENV["RELATION"] | |
18 | + | |
17 | 19 | # add to elasticsearch-7.0.0/config/ |
18 | 20 | Searchkick.wordnet_path = "wn_s.pl" if ENV["WORDNET"] |
19 | 21 | ... | ... |