searchkick 5.0.5 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a93f95464f2b83d27f621d925326ea3b7728b2d71fff9831e20e07658ff0466
4
- data.tar.gz: acf15b38474dea853f3e3574ea5fac21d4129920b6365e2c92ca58cfaf518cc0
3
+ metadata.gz: dcb83468ee84892db5a2484a3d5ec75bb9b8964fd0a9b9c3ab73b735f8467390
4
+ data.tar.gz: d309602fe457bf39fd170d2bcf446119d4a2a93ea669df833b21bf1b0ef76a4b
5
5
  SHA512:
6
- metadata.gz: 51f9d3b6c110a7ec24988518b7e154fef368c2d027c00337e54096c3214871d29da9bdc9e549d4b9967742636bb8ae60d5a288ca066ff992691692a017b9bdda
7
- data.tar.gz: 811825c1043231828c2d04a3a2081e453440fd470563680c8e470fea00569ffe57109bca64e07978ba8944d53a03f95c9fd4768872d6bf2ae6c4e87ede961e7a
6
+ metadata.gz: 196f076e15d708c89ae13ddb96ef7fce4cd19de9b5cfef639ea68e8886e81a66b1f01ed1f5453065ad58c617a42aceeda493ac6bc5c34e89cb08956be35eb87d
7
+ data.tar.gz: ac58225f370165c19a9378c3c84e07aedc297ae7f263cb1c027f5536184e4fe336b540726e6adf6ac1aca6802e424026a448d783d1e4a4279e03db01931b707c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 5.1.1 (2022-12-05)
2
+
3
+ - Added support for strings for `offset` and `per_page`
4
+
5
+ ## 5.1.0 (2022-10-12)
6
+
7
+ - Added support for fractional search timeout
8
+ - Fixed search timeout with `elasticsearch` 8+ and `opensearch-ruby` gems
9
+ - Fixed search timeout not applying to `multi_search`
10
+
1
11
  ## 5.0.5 (2022-10-09)
2
12
 
3
13
  - Added `model` method to `Searchkick::Relation`
data/README.md CHANGED
@@ -1112,7 +1112,7 @@ Restaurant.search("soup", where: {bounds: {geo_shape: {type: "polygon", coordina
1112
1112
  Falling entirely within the query shape
1113
1113
 
1114
1114
  ```ruby
1115
- Restaurant.search("salad", where: {bounds: {geo_shape: {type: "circle", relation: "within", coordinates: [{lat: 38, lon: -123}], radius: "1km"}}})
1115
+ Restaurant.search("salad", where: {bounds: {geo_shape: {type: "circle", relation: "within", coordinates: {lat: 38, lon: -123}, radius: "1km"}}})
1116
1116
  ```
1117
1117
 
1118
1118
  Not touching the query shape
@@ -3,8 +3,15 @@ require "faraday"
3
3
  module Searchkick
4
4
  class Middleware < Faraday::Middleware
5
5
  def call(env)
6
- if env[:method] == :get && env[:url].path.to_s.end_with?("/_search")
6
+ path = env[:url].path.to_s
7
+ if path.end_with?("/_search")
7
8
  env[:request][:timeout] = Searchkick.search_timeout
9
+ elsif path.end_with?("/_msearch")
10
+ # assume no concurrent searches for timeout for now
11
+ searches = env[:request_body].count("\n") / 2
12
+ # do not allow timeout to exceed Searchkick.timeout
13
+ timeout = [Searchkick.search_timeout * searches, Searchkick.timeout].min
14
+ env[:request][:timeout] = timeout
8
15
  end
9
16
  @app.call(env)
10
17
  end
@@ -251,7 +251,7 @@ module Searchkick
251
251
  default_limit = searchkick_options[:deep_paging] ? 1_000_000_000 : 10_000
252
252
  per_page = (options[:limit] || options[:per_page] || default_limit).to_i
253
253
  padding = [options[:padding].to_i, 0].max
254
- offset = options[:offset] || (page - 1) * per_page + padding
254
+ offset = (options[:offset] || (page - 1) * per_page + padding).to_i
255
255
  scroll = options[:scroll]
256
256
 
257
257
  max_result_window = searchkick_options[:max_result_window]
@@ -505,7 +505,7 @@ module Searchkick
505
505
  set_highlights(payload, fields) if options[:highlight]
506
506
 
507
507
  # timeout shortly after client times out
508
- payload[:timeout] ||= "#{Searchkick.search_timeout + 1}s"
508
+ payload[:timeout] ||= "#{((Searchkick.search_timeout + 1) * 1000).round}ms"
509
509
 
510
510
  # An empty array will cause only the _id and _type for each hit to be returned
511
511
  # https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "5.0.5"
2
+ VERSION = "5.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.5
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel