search_flip 3.8.0 → 3.9.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: b27a32f7b2d3ccedcdc823cbd8b8682027868e3d74cf1c135404b71dfec5f337
4
- data.tar.gz: 00f45e2024a1ef108a3e8132794c036f2514ae015c13a7e7d3266b9580e44a6b
3
+ metadata.gz: fe72863b41e604e0e1faf6148099a0fd1e8f2619e9224dfc1a77015534574c5a
4
+ data.tar.gz: c199afecd685aebb5e250be8d0b4760e4b513e7aafc5475d45e471458dad12ae
5
5
  SHA512:
6
- metadata.gz: 635e6b47c05282a3f55ba35bea4b6a7fa9d4743ca911483c41ce8d994fd5830eea5c80027283f6bcda025722fe46bb42d56ee72e7242d296f569e69b756b44af
7
- data.tar.gz: d754585b03d8d2cd996b7c215b6ac939d9a8c6d6fdcdebc8aaf73143ab5f2b7499925120886ef0dbe2d88caf9eb137317426012a283a6e7050fdac2b1b19ac80
6
+ metadata.gz: ade3326e113e4132f12d35d65b962145b8a3fc8ed9eddd2e6ae99dc235805486e578f665973e6db9e60e402f4a915c7f42785e70790f0e7adefdad62e6881824
7
+ data.tar.gz: 4660765f5157949a6729a7de370e7816c3400341fb9521cbec0209e091e42ce460670ff3744d3ffb2a7b3650a051caa404e67b8a77dd27da0af1ef7690be2bb2
@@ -1,4 +1,4 @@
1
- on: push
1
+ on: [push, pull_request]
2
2
  name: test
3
3
  jobs:
4
4
  test:
@@ -27,7 +27,7 @@ jobs:
27
27
  env:
28
28
  discovery.type: single-node
29
29
  xpack.security.enabled: false
30
- - image: docker.elastic.co/elasticsearch/elasticsearch:8.1.1
30
+ - image: docker.elastic.co/elasticsearch/elasticsearch:8.11.4
31
31
  env:
32
32
  discovery.type: single-node
33
33
  xpack.security.enabled: false
@@ -39,6 +39,10 @@ jobs:
39
39
  env:
40
40
  discovery.type: single-node
41
41
  plugins.security.disabled: true
42
+ - image: opensearchproject/opensearch:2.13.0
43
+ env:
44
+ discovery.type: single-node
45
+ DISABLE_SECURITY_PLUGIN: true
42
46
  ruby:
43
47
  - 2.7
44
48
  - 3.0
@@ -50,6 +54,11 @@ jobs:
50
54
  env: ${{ matrix.elasticsearch.env }}
51
55
  ports:
52
56
  - 9200:9200
57
+ options: >-
58
+ --health-cmd "curl -sf http://localhost:9200 || exit 1"
59
+ --health-interval 10s
60
+ --health-timeout 5s
61
+ --health-retries 30
53
62
  steps:
54
63
  - uses: actions/checkout@v1
55
64
  - uses: ruby/setup-ruby@v1
data/.rubocop.yml CHANGED
@@ -3,6 +3,9 @@ AllCops:
3
3
  TargetRubyVersion: 2.5
4
4
  SuggestExtensions: false
5
5
 
6
+ Naming/PredicateMethod:
7
+ Enabled: false
8
+
6
9
  Gemspec/RequireMFA:
7
10
  Enabled: false
8
11
 
data/CHANGELOG.md CHANGED
@@ -1,7 +1,24 @@
1
1
 
2
2
  # CHANGELOG
3
3
 
4
- ## v3.8.0.
4
+ ## v3.9.1
5
+
6
+ * Fix compatibility with http.rb version 6
7
+
8
+ ## v3.9.0
9
+
10
+ * Allow to configure the elasticsearch version no matter which elasticsearch
11
+ version is actually in use. The version information is needed to support
12
+ version dependent features. Please note that manually configuring the version
13
+ is usually not need as the version by default is determined by sending one
14
+ request to elasticsearch.
15
+
16
+ ```ruby
17
+ SearchFlip::Config[:version] = { number: "8.1.1" }
18
+ SearchFlip::Config[:version] = { number: "2.13", distribution: "opensearch" }
19
+ ```
20
+
21
+ ## v3.8.0
5
22
 
6
23
  * Support Opensearch 1.x and 2.x
7
24
 
data/Gemfile CHANGED
@@ -14,6 +14,6 @@ gem "factory_bot"
14
14
  gem "rake"
15
15
  gem "rspec"
16
16
  gem "rubocop"
17
- gem "sqlite3"
17
+ gem "sqlite3", ">= 1.4"
18
18
  gem "timecop"
19
19
  gem "webmock"
data/README.md CHANGED
@@ -98,6 +98,16 @@ Available config options are:
98
98
  * `auto_refresh` tells SearchFlip to automatically refresh an index after
99
99
  import, index, delete, etc operations. This is e.g. useful for testing, etc.
100
100
  Defaults to false.
101
+ * `version` allows to configure the elasticsearch version no matter which
102
+ elasticsearch version is actually in use. The version information is needed to
103
+ support version dependent features. Please note that manually configuring the
104
+ version is usually not need as the version by default is determined by sending
105
+ one request to elasticsearch.
106
+
107
+ ```ruby
108
+ SearchFlip::Config[:version] = { number: "8.1.1" }
109
+ SearchFlip::Config[:version] = { number: "2.13", distribution: "opensearch" }
110
+ ```
101
111
 
102
112
  ## Usage
103
113
 
@@ -33,9 +33,9 @@ module SearchFlip
33
33
  if target.connection.distribution || target.connection.version.to_i >= 2
34
34
  res[:filter] = {
35
35
  bool: {}
36
- .merge(must_values ? { must: must_values } : {})
37
- .merge(must_not_values ? { must_not: must_not_values } : {})
38
- .merge(filter_values ? { filter: filter_values } : {})
36
+ .merge(must_values ? { must: must_values } : {})
37
+ .merge(must_not_values ? { must_not: must_not_values } : {})
38
+ .merge(filter_values ? { filter: filter_values } : {})
39
39
  }
40
40
  else
41
41
  filters = (filter_values || []) + (must_not_values || []).map { |must_not_value| { not: must_not_value } }
@@ -26,7 +26,7 @@ module SearchFlip
26
26
  # @return [String] The Elasticsearch distribution
27
27
 
28
28
  def distribution
29
- @distribution ||= SearchFlip::JSON.parse(version_response.to_s)["version"]["distribution"]
29
+ @distribution ||= SearchFlip::Config.dig(:version, :distribution) || SearchFlip::JSON.parse(version_response.to_s)["version"]["distribution"]
30
30
  end
31
31
 
32
32
  # Queries and returns the Elasticsearch version used.
@@ -37,7 +37,7 @@ module SearchFlip
37
37
  # @return [String] The Elasticsearch version
38
38
 
39
39
  def version
40
- @version ||= SearchFlip::JSON.parse(version_response.to_s)["version"]["number"]
40
+ @version ||= SearchFlip::Config.dig(:version, :number) || SearchFlip::JSON.parse(version_response.to_s)["version"]["number"]
41
41
  end
42
42
 
43
43
  # Queries and returns the Elasticsearch cluster health.
@@ -73,7 +73,7 @@ module SearchFlip
73
73
  final_request = plugins.inject(final_request) { |res, cur| cur.call(res, method, uri, opts) }
74
74
  final_request = final_request.headers({}) # Prevent thread-safety issue of http-rb: https://github.com/httprb/http/issues/558
75
75
 
76
- response = final_request.request.send(method, uri, opts)
76
+ response = final_request.request.send(method, uri, **opts)
77
77
 
78
78
  raise SearchFlip::ResponseError.new(code: response.code, body: response.body.to_s) unless response.status.success?
79
79
 
@@ -1,3 +1,3 @@
1
1
  module SearchFlip
2
- VERSION = "3.8.0"
2
+ VERSION = "3.9.1"
3
3
  end
@@ -5,12 +5,28 @@ RSpec.describe SearchFlip::Connection do
5
5
  it "reutrns the distribution" do
6
6
  expect([nil, "opensearch"]).to include(SearchFlip::Connection.new.distribution)
7
7
  end
8
+
9
+ it "returns the distribution from the config when given" do
10
+ SearchFlip::Config[:version] = { distribution: "distribution" }
11
+
12
+ expect(SearchFlip::Connection.new.distribution).to eq("distribution")
13
+ ensure
14
+ SearchFlip::Config.delete(:version)
15
+ end
8
16
  end
9
17
 
10
18
  describe "#version" do
11
19
  it "returns the version" do
12
20
  expect(SearchFlip::Connection.new.version).to match(/\A[0-9.]+\z/)
13
21
  end
22
+
23
+ it "returns the version from the config when given" do
24
+ SearchFlip::Config[:version] = { number: "1.2.3" }
25
+
26
+ expect(SearchFlip::Connection.new.version).to eq("1.2.3")
27
+ ensure
28
+ SearchFlip::Config.delete(:version)
29
+ end
14
30
  end
15
31
 
16
32
  describe "#cluster_health" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 3.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-19 00:00:00.000000000 Z
11
+ date: 2026-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie