Commit a7b7908f037ff550e525c5e10a827a2f910aa4f1
1 parent
28007e3d
Exists in
relation
and in
1 other branch
Added body_options and request params
Showing
2 changed files
with
24 additions
and
0 deletions
Show diff stats
lib/searchkick/relation.rb
... | ... | @@ -276,6 +276,24 @@ module Searchkick |
276 | 276 | self |
277 | 277 | end |
278 | 278 | |
279 | + def body_options(value) | |
280 | + spawn.body_options!(value) | |
281 | + end | |
282 | + | |
283 | + def body_options!(value) | |
284 | + options[:body_options] = value | |
285 | + self | |
286 | + end | |
287 | + | |
288 | + def request_params(value) | |
289 | + spawn.request_params!(value) | |
290 | + end | |
291 | + | |
292 | + def request_params!(value) | |
293 | + options[:request_params] = value | |
294 | + self | |
295 | + end | |
296 | + | |
279 | 297 | # same as Active Record |
280 | 298 | def inspect |
281 | 299 | entries = results.first(11).map!(&:inspect) | ... | ... |
test/query_test.rb
... | ... | @@ -14,6 +14,11 @@ class QueryTest < Minitest::Test |
14 | 14 | assert_search "milk", ["Milk", "Milk2"], body_options: {min_score: 0.0001} |
15 | 15 | end |
16 | 16 | |
17 | + def test_body_options | |
18 | + store_names ["Milk", "Milk2"] | |
19 | + assert_search_relation ["Milk", "Milk2"], Product.search("milk", relation: true).body_options(min_score: 0.0001) | |
20 | + end | |
21 | + | |
17 | 22 | def test_default_timeout |
18 | 23 | assert_equal "6s", Product.search("*", execute: false).body[:timeout] |
19 | 24 | end |
... | ... | @@ -24,6 +29,7 @@ class QueryTest < Minitest::Test |
24 | 29 | |
25 | 30 | def test_request_params |
26 | 31 | assert_equal "dfs_query_then_fetch", Product.search("*", request_params: {search_type: "dfs_query_then_fetch"}, execute: false).params[:search_type] |
32 | + assert_equal "dfs_query_then_fetch", Product.search("*", relation: true).request_params(search_type: "dfs_query_then_fetch").query.params[:search_type] | |
27 | 33 | end |
28 | 34 | |
29 | 35 | def test_debug | ... | ... |