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,7 +36,7 @@ module Searchkick | ||
36 | class ImportError < Error; end | 36 | class ImportError < Error; end |
37 | 37 | ||
38 | class << self | 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 | attr_writer :client, :env, :search_timeout | 40 | attr_writer :client, :env, :search_timeout |
41 | attr_reader :aws_credentials | 41 | attr_reader :aws_credentials |
42 | end | 42 | end |
@@ -47,6 +47,7 @@ module Searchkick | @@ -47,6 +47,7 @@ module Searchkick | ||
47 | self.client_options = {} | 47 | self.client_options = {} |
48 | self.queue_name = :searchkick | 48 | self.queue_name = :searchkick |
49 | self.model_options = {} | 49 | self.model_options = {} |
50 | + self.relation = false | ||
50 | 51 | ||
51 | def self.client | 52 | def self.client |
52 | @client ||= begin | 53 | @client ||= begin |
@@ -113,7 +114,7 @@ module Searchkick | @@ -113,7 +114,7 @@ module Searchkick | ||
113 | end | 114 | end |
114 | 115 | ||
115 | options = options.merge(block: block) if block | 116 | options = options.merge(block: block) if block |
116 | - if relation | 117 | + if relation || (relation.nil? && Searchick.relation) |
117 | Searchkick::Relation.new(klass, term, **options) | 118 | Searchkick::Relation.new(klass, term, **options) |
118 | else | 119 | else |
119 | query = Searchkick::Query.new(klass, term, **options) | 120 | query = Searchkick::Query.new(klass, term, **options) |
test/test_helper.rb
@@ -14,6 +14,8 @@ Searchkick.client.transport.logger = $logger | @@ -14,6 +14,8 @@ Searchkick.client.transport.logger = $logger | ||
14 | Searchkick.search_timeout = 5 | 14 | Searchkick.search_timeout = 5 |
15 | Searchkick.index_suffix = ENV["TEST_ENV_NUMBER"] # for parallel tests | 15 | Searchkick.index_suffix = ENV["TEST_ENV_NUMBER"] # for parallel tests |
16 | 16 | ||
17 | +Searchkick.relation = ENV["RELATION"] | ||
18 | + | ||
17 | # add to elasticsearch-7.0.0/config/ | 19 | # add to elasticsearch-7.0.0/config/ |
18 | Searchkick.wordnet_path = "wn_s.pl" if ENV["WORDNET"] | 20 | Searchkick.wordnet_path = "wn_s.pl" if ENV["WORDNET"] |
19 | 21 |