Commit 495599f68e85e9c4fd8a0f049e09484e5c3bf3c4

Authored by Andrew Kane
1 parent 9febe2f8

Added request_params option - #484

CHANGELOG.md
  1 +## 1.3.5 [unreleased]
  2 +
  3 +- Added `request_params` option
  4 +
1 5 ## 1.3.4
2 6  
3 7 - Added `resume` option to reindex
... ...
README.md
... ... @@ -1314,6 +1314,12 @@ products = Product.search("carrots", execute: false)
1314 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 1323 Make fields unsearchable but include in the source
1318 1324  
1319 1325 ```ruby
... ...
lib/searchkick/query.rb
... ... @@ -61,6 +61,7 @@ module Searchkick
61 61 }
62 62 params.merge!(type: @type) if @type
63 63 params.merge!(routing: @routing) if @routing
  64 + params.merge!(options[:request_params]) if options[:request_params]
64 65 params
65 66 end
66 67  
... ...
test/query_test.rb
... ... @@ -28,4 +28,8 @@ class QueryTest < Minitest::Test
28 28 def test_timeout_override
29 29 assert_equal "1s", Product.search("*", body_options: {timeout: "1s"}, execute: false).body[:timeout]
30 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 35 end
... ...