Commit 495599f68e85e9c4fd8a0f049e09484e5c3bf3c4

Authored by Andrew Kane
1 parent 9febe2f8

Added request_params option - #484

  1 +## 1.3.5 [unreleased]
  2 +
  3 +- Added `request_params` option
  4 +
1 ## 1.3.4 5 ## 1.3.4
2 6
3 - Added `resume` option to reindex 7 - Added `resume` option to reindex
@@ -1314,6 +1314,12 @@ products = Product.search("carrots", execute: false) @@ -1314,6 +1314,12 @@ products = Product.search("carrots", execute: false)
1314 products.each { ... } # search not executed until here 1314 products.each { ... } # search not executed until here
1315 ``` 1315 ```
1316 1316
  1317 +Add [request parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html), like `search_type` and `query_cache` [master]
  1318 +
  1319 +```ruby
  1320 +Product.search("carrots", request_params: {search_type: "dfs_query_then_fetch"})
  1321 +```
  1322 +
1317 Make fields unsearchable but include in the source 1323 Make fields unsearchable but include in the source
1318 1324
1319 ```ruby 1325 ```ruby
lib/searchkick/query.rb
@@ -61,6 +61,7 @@ module Searchkick @@ -61,6 +61,7 @@ module Searchkick
61 } 61 }
62 params.merge!(type: @type) if @type 62 params.merge!(type: @type) if @type
63 params.merge!(routing: @routing) if @routing 63 params.merge!(routing: @routing) if @routing
  64 + params.merge!(options[:request_params]) if options[:request_params]
64 params 65 params
65 end 66 end
66 67
test/query_test.rb
@@ -28,4 +28,8 @@ class QueryTest < Minitest::Test @@ -28,4 +28,8 @@ class QueryTest < Minitest::Test
28 def test_timeout_override 28 def test_timeout_override
29 assert_equal "1s", Product.search("*", body_options: {timeout: "1s"}, execute: false).body[:timeout] 29 assert_equal "1s", Product.search("*", body_options: {timeout: "1s"}, execute: false).body[:timeout]
30 end 30 end
  31 +
  32 + def test_request_params
  33 + assert_equal "dfs_query_then_fetch", Product.search("*", request_params: {search_type: "dfs_query_then_fetch"}, execute: false).params[:search_type]
  34 + end
31 end 35 end