elasticsearch 8.19.3 → 9.0.0

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: d756d2e7b4365dfa67b659e09cb234f91c2d00ff0f7b25c69faee2e32e21a34a
4
- data.tar.gz: 3bc765b02ebf270011599718e0070be68132b5df040d710da0cd793c8030525a
3
+ metadata.gz: 26ff9ee984327ed517e9aa27be77fd79247e23b0e3ccd080c6c091e496b0b49d
4
+ data.tar.gz: 2f5a3f30af1ad0dc0f4d568bcc7d89e8ad1bfc16469ee5672dcc57a81687cc63
5
5
  SHA512:
6
- metadata.gz: ecaaa74c9e631068a92fb38feab3c99b4e1214a3b9a771e8af03976d3e40d691b44727a2c8bf435e0f40bb75d5545ccdd8e492c576c609b16a66acd6ad9ad12a
7
- data.tar.gz: 4c00f1ebef1364165cc63ad4cd5b6bbd100de4055f2b620fc5fdda6eec130ce7b314a92bb1385a069dba627475ae522eb4e149111cc0e3718434302ec732b6b7
6
+ metadata.gz: 5588870792cefa5145db01cc7e1bbc04d1d90f69af0f10db72c83041209c5d9e6f873e44552745a646af27ca679260a92e3dcedce24d57d827543e471e9803e7
7
+ data.tar.gz: '0817be29b78c69cac36d09fe454857916df101b685d0d8e544ecaf0cc76b36e8f0e83e7c504fd7cf5f2d394b830ae1136d225786d5c9a6cddc623f3d0e3c5b79'
@@ -15,7 +15,7 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
- lib = File.expand_path('../lib', __FILE__)
18
+ lib = File.expand_path('lib', __dir__)
19
19
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
20
20
  require 'elasticsearch/version'
21
21
 
@@ -33,21 +33,21 @@ Gem::Specification.new do |s|
33
33
  'source_code_uri' => 'https://github.com/elastic/elasticsearch-ruby/tree/main',
34
34
  'bug_tracker_uri' => 'https://github.com/elastic/elasticsearch-ruby/issues'
35
35
  }
36
- s.files = `git ls-files`.split($/)
36
+ s.files = `git ls-files`.split($/).reject do |file|
37
+ file.match(/^spec\/|^Gemfile|^Rakefile/)
38
+ end
39
+
37
40
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
38
41
  s.executables << 'elastic_ruby_console'
39
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
40
42
  s.require_paths = ['lib']
41
43
  s.bindir = 'bin'
42
44
 
43
45
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
44
46
  s.rdoc_options = ['--charset=UTF-8']
45
47
 
46
- s.required_ruby_version = '>= 2.5'
47
-
48
+ s.required_ruby_version = '>= 2.6' # For compatibility with JRuby 9.3
49
+ s.add_dependency 'elasticsearch-api', '9.0.0'
48
50
  s.add_dependency 'elastic-transport', '~> 8.3'
49
- s.add_dependency 'elasticsearch-api', '8.19.3'
50
- s.add_dependency 'ostruct' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4')
51
51
 
52
52
  s.add_development_dependency 'base64'
53
53
  s.add_development_dependency 'bundler'
@@ -16,5 +16,5 @@
16
16
  # under the License.
17
17
 
18
18
  module Elasticsearch
19
- VERSION = '8.19.3'.freeze
19
+ VERSION = '9.0.0'.freeze
20
20
  end
data/lib/elasticsearch.rb CHANGED
@@ -37,8 +37,9 @@ module Elasticsearch
37
37
  #
38
38
  # @param [Hash] arguments - initializer arguments
39
39
  # @option arguments [String] :cloud_id - The Cloud ID to connect to Elastic Cloud
40
- # @option arguments [String, Hash] :api_key Use API Key Authentication, either the base64 encoding of `id` and `api_key`
41
- # joined by a colon as a String, or a hash with the `id` and `api_key` values.
40
+ # @option arguments [String, Hash] :api_key Use API Key Authentication, either the base64 encoding of `id` and
41
+ # `api_key` joined by a colon as a String, or a hash with the `id` and
42
+ # `api_key` values.
42
43
  # @option arguments [String] :opaque_id_prefix set a prefix for X-Opaque-Id when initializing the client.
43
44
  # This will be prepended to the id you set before each request
44
45
  # if you're using X-Opaque-Id
@@ -65,10 +66,10 @@ module Elasticsearch
65
66
  opaque_id = @opaque_id_prefix ? "#{@opaque_id_prefix}#{opaque_id}" : opaque_id
66
67
  args[4] = headers.merge('X-Opaque-Id' => opaque_id)
67
68
  end
68
- unless @verified
69
- verify_elasticsearch(*args, &block)
70
- else
69
+ if @verified
71
70
  @transport.perform_request(*args, &block)
71
+ else
72
+ verify_elasticsearch(*args, &block)
72
73
  end
73
74
  else
74
75
  @transport.send(name, *args, &block)
@@ -101,6 +102,7 @@ module Elasticsearch
101
102
  raise e
102
103
  end
103
104
  raise Elasticsearch::UnsupportedProductError unless response.headers['x-elastic-product'] == 'Elasticsearch'
105
+
104
106
  @verified = true
105
107
  response
106
108
  end
@@ -175,7 +177,7 @@ module Elasticsearch
175
177
  end
176
178
  arguments[:transport_options] ||= {}
177
179
  arguments[:transport_options][:headers] ||= {}
178
- arguments[:transport_options][:headers].merge!({ user_agent: user_agent.join('; ')})
180
+ arguments[:transport_options][:headers].merge!({ user_agent: user_agent.join('; ') })
179
181
  end
180
182
  end
181
183
 
metadata CHANGED
@@ -1,56 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.19.3
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic Client Library Maintainers
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2025-04-15 00:00:00.000000000 Z
11
11
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: elastic-transport
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: '8.3'
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - "~>"
24
- - !ruby/object:Gem::Version
25
- version: '8.3'
26
12
  - !ruby/object:Gem::Dependency
27
13
  name: elasticsearch-api
28
14
  requirement: !ruby/object:Gem::Requirement
29
15
  requirements:
30
16
  - - '='
31
17
  - !ruby/object:Gem::Version
32
- version: 8.19.3
18
+ version: 9.0.0
33
19
  type: :runtime
34
20
  prerelease: false
35
21
  version_requirements: !ruby/object:Gem::Requirement
36
22
  requirements:
37
23
  - - '='
38
24
  - !ruby/object:Gem::Version
39
- version: 8.19.3
25
+ version: 9.0.0
40
26
  - !ruby/object:Gem::Dependency
41
- name: ostruct
27
+ name: elastic-transport
42
28
  requirement: !ruby/object:Gem::Requirement
43
29
  requirements:
44
- - - ">="
30
+ - - "~>"
45
31
  - !ruby/object:Gem::Version
46
- version: '0'
32
+ version: '8.3'
47
33
  type: :runtime
48
34
  prerelease: false
49
35
  version_requirements: !ruby/object:Gem::Requirement
50
36
  requirements:
51
- - - ">="
37
+ - - "~>"
52
38
  - !ruby/object:Gem::Version
53
- version: '0'
39
+ version: '8.3'
54
40
  - !ruby/object:Gem::Dependency
55
41
  name: base64
56
42
  requirement: !ruby/object:Gem::Requirement
@@ -214,14 +200,12 @@ executables:
214
200
  - elastic_ruby_console
215
201
  extensions: []
216
202
  extra_rdoc_files:
217
- - LICENSE.txt
218
203
  - README.md
204
+ - LICENSE.txt
219
205
  files:
220
206
  - ".gitignore"
221
- - Gemfile
222
207
  - LICENSE.txt
223
208
  - README.md
224
- - Rakefile
225
209
  - bin/elastic_ruby_console
226
210
  - elasticsearch.gemspec
227
211
  - lib/elasticsearch-ruby.rb
@@ -230,22 +214,6 @@ files:
230
214
  - lib/elasticsearch/helpers/esql_helper.rb
231
215
  - lib/elasticsearch/helpers/scroll_helper.rb
232
216
  - lib/elasticsearch/version.rb
233
- - spec/integration/characters_escaping_spec.rb
234
- - spec/integration/client_integration_spec.rb
235
- - spec/integration/helpers/bulk_helper_spec.rb
236
- - spec/integration/helpers/esql_helper_spec.rb
237
- - spec/integration/helpers/helpers_spec_helper.rb
238
- - spec/integration/helpers/scroll_helper_spec.rb
239
- - spec/integration/opentelemetry_spec.rb
240
- - spec/spec_helper.rb
241
- - spec/unit/api_key_spec.rb
242
- - spec/unit/cloud_credentials_spec.rb
243
- - spec/unit/custom_transport_implementation_spec.rb
244
- - spec/unit/elasticsearch_product_validation_spec.rb
245
- - spec/unit/headers_spec.rb
246
- - spec/unit/opaque_id_spec.rb
247
- - spec/unit/user_agent_spec.rb
248
- - spec/unit/wrapper_gem_spec.rb
249
217
  homepage: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html
250
218
  licenses:
251
219
  - Apache-2.0
@@ -262,30 +230,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
230
  requirements:
263
231
  - - ">="
264
232
  - !ruby/object:Gem::Version
265
- version: '2.5'
233
+ version: '2.6'
266
234
  required_rubygems_version: !ruby/object:Gem::Requirement
267
235
  requirements:
268
236
  - - ">="
269
237
  - !ruby/object:Gem::Version
270
238
  version: '0'
271
239
  requirements: []
272
- rubygems_version: 4.0.3
240
+ rubygems_version: 3.6.2
273
241
  specification_version: 4
274
242
  summary: Ruby integrations for Elasticsearch
275
- test_files:
276
- - spec/integration/characters_escaping_spec.rb
277
- - spec/integration/client_integration_spec.rb
278
- - spec/integration/helpers/bulk_helper_spec.rb
279
- - spec/integration/helpers/esql_helper_spec.rb
280
- - spec/integration/helpers/helpers_spec_helper.rb
281
- - spec/integration/helpers/scroll_helper_spec.rb
282
- - spec/integration/opentelemetry_spec.rb
283
- - spec/spec_helper.rb
284
- - spec/unit/api_key_spec.rb
285
- - spec/unit/cloud_credentials_spec.rb
286
- - spec/unit/custom_transport_implementation_spec.rb
287
- - spec/unit/elasticsearch_product_validation_spec.rb
288
- - spec/unit/headers_spec.rb
289
- - spec/unit/opaque_id_spec.rb
290
- - spec/unit/user_agent_spec.rb
291
- - spec/unit/wrapper_gem_spec.rb
243
+ test_files: []
data/Gemfile DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Licensed to Elasticsearch B.V. under one or more contributor
4
- # license agreements. See the NOTICE file distributed with
5
- # this work for additional information regarding copyright
6
- # ownership. Elasticsearch B.V. licenses this file to you under
7
- # the Apache License, Version 2.0 (the "License"); you may
8
- # not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- source 'https://rubygems.org'
21
-
22
- # Specify your gem's dependencies in elasticsearch.gemspec
23
- gemspec
24
-
25
- if File.exist? File.expand_path('../elasticsearch-api/elasticsearch-api.gemspec', __dir__)
26
- gem 'elasticsearch-api', path: File.expand_path('../elasticsearch-api', __dir__), require: false
27
- end
28
-
29
- if ENV['TRANSPORT_VERSION'] == 'main'
30
- gem 'elastic-transport', git: 'https://github.com/elastic/elastic-transport-ruby.git', branch: 'main'
31
- end
32
-
33
- if RUBY_VERSION >= '3.0'
34
- gem 'opentelemetry-sdk', require: false
35
- end
data/Rakefile DELETED
@@ -1,54 +0,0 @@
1
- # Licensed to Elasticsearch B.V. under one or more contributor
2
- # license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright
4
- # ownership. Elasticsearch B.V. licenses this file to you under
5
- # the Apache License, Version 2.0 (the "License"); you may
6
- # not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing,
12
- # software distributed under the License is distributed on an
13
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- # KIND, either express or implied. See the License for the
15
- # specific language governing permissions and limitations
16
- # under the License.
17
-
18
- require 'bundler/gem_tasks'
19
-
20
- task(:default) { system 'rake --tasks' }
21
-
22
- desc 'Run unit tests'
23
- task test: 'test:spec'
24
-
25
- # ----- Test tasks ------------------------------------------------------------
26
- require 'rspec/core/rake_task'
27
-
28
- namespace :test do
29
- desc 'Wait for Elasticsearch to be in a green state'
30
- task :wait_for_green do
31
- sh '../scripts/wait-cluster.sh'
32
- end
33
-
34
- RSpec::Core::RakeTask.new(:integration) do |t|
35
- t.pattern = 'spec/integration/**{,/*/**}/*_spec.rb'
36
- end
37
-
38
- RSpec::Core::RakeTask.new(:unit) do |t|
39
- t.pattern = 'spec/unit/**{,/*/**}/*_spec.rb'
40
- end
41
-
42
- desc 'Run unit and integration tests'
43
- task :all do
44
- Rake::Task['test:unit'].invoke
45
- Rake::Task['test:integration'].invoke
46
- end
47
- end
48
-
49
- # ----- Documentation tasks ---------------------------------------------------
50
-
51
- require 'yard'
52
- YARD::Rake::YardocTask.new(:doc) do |t|
53
- t.options = %w| --embed-mixins --markup=markdown |
54
- end
@@ -1,96 +0,0 @@
1
- # Licensed to Elasticsearch B.V. under one or more contributor
2
- # license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright
4
- # ownership. Elasticsearch B.V. licenses this file to you under
5
- # the Apache License, Version 2.0 (the "License"); you may
6
- # not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing,
12
- # software distributed under the License is distributed on an
13
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- # KIND, either express or implied. See the License for the
15
- # specific language governing permissions and limitations
16
- # under the License.
17
-
18
- require 'spec_helper'
19
- require 'uri'
20
-
21
- ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}"
22
- raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
23
-
24
- context 'Elasticsearch client' do
25
- let(:client) do
26
- Elasticsearch::Client.new(host: ELASTICSEARCH_URL, user: 'elastic', password: 'changeme')
27
- end
28
- let(:index) { 'tvs' }
29
-
30
- after do
31
- client.indices.delete(index: index)
32
- end
33
-
34
- context 'escaping spaces in ids' do
35
- it 'escapes spaces for id when using index' do
36
- response = client.index(index: index, id: 'a test 1', body: { name: 'A test 1' }, refresh: true)
37
- expect(response.body['_id']).to eq 'a test 1'
38
-
39
- response = client.search(index: index)
40
- expect(response.body['hits']['hits'].first['_id']).to eq 'a test 1'
41
-
42
- # Raises exception, _id is unrecognized
43
- expect do
44
- client.index(index: index, _id: 'a test 2', body: { name: 'A test 2' })
45
- end.to raise_exception Elastic::Transport::Transport::Errors::BadRequest
46
-
47
- # Raises exception, id is a query parameter
48
- expect do
49
- client.index(index: index, body: { name: 'A test 3', _id: 'a test 3' })
50
- end.to raise_exception Elastic::Transport::Transport::Errors::BadRequest
51
- end
52
-
53
- it 'escapes spaces for id when using create' do
54
- # Works with create
55
- response = client.create(index: index, id: 'a test 4', body: { name: 'A test 4' })
56
- expect(response.body['_id']).to eq 'a test 4'
57
- end
58
-
59
- it 'escapes spaces for id when using bulk' do
60
- body = [
61
- { create: { _index: index, _id: 'a test 5', data: { name: 'A test 5' } } }
62
- ]
63
- expect(client.bulk(body: body, refresh: true).status).to eq 200
64
-
65
- response = client.search(index: index)
66
- expect(
67
- response.body['hits']['hits'].select { |a| a['_id'] == 'a test 5' }.size
68
- ).to eq 1
69
- end
70
- end
71
-
72
- context 'it doesnae escape plus signs in id' do
73
- it 'escapes spaces for id when using index' do
74
- response = client.index(index: index, id: 'a+test+1', body: { name: 'A test 1' })
75
- expect(response.body['_id']).to eq 'a+test+1'
76
- end
77
-
78
- it 'escapes spaces for id when using create' do
79
- # Works with create
80
- response = client.create(index: index, id: 'a+test+2', body: { name: 'A test 2' })
81
- expect(response.body['_id']).to eq 'a+test+2'
82
- end
83
-
84
- it 'escapes spaces for id when using bulk' do
85
- body = [
86
- { create: { _index: index, _id: 'a+test+3', data: { name: 'A test 3' } } }
87
- ]
88
- expect(client.bulk(body: body, refresh: true).status).to eq 200
89
-
90
- response = client.search(index: index)
91
- expect(
92
- response.body['hits']['hits'].select { |a| a['_id'] == 'a+test+3' }.size
93
- ).to eq 1
94
- end
95
- end
96
- end
@@ -1,64 +0,0 @@
1
- # Licensed to Elasticsearch B.V. under one or more contributor
2
- # license agreements. See the NOTICE file distributed with
3
- # this work for additional information regarding copyright
4
- # ownership. Elasticsearch B.V. licenses this file to you under
5
- # the Apache License, Version 2.0 (the "License"); you may
6
- # not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing,
12
- # software distributed under the License is distributed on an
13
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- # KIND, either express or implied. See the License for the
15
- # specific language governing permissions and limitations
16
- # under the License.
17
- ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}"
18
- raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
19
-
20
- require 'spec_helper'
21
- require 'logger'
22
- require 'uri'
23
-
24
- context 'Elasticsearch client' do
25
- let(:logger) { Logger.new($stderr) }
26
-
27
- let(:client) do
28
- Elasticsearch::Client.new(
29
- host: ELASTICSEARCH_URL,
30
- logger: logger,
31
- user: 'elastic',
32
- password: 'changeme'
33
- )
34
- end
35
-
36
- context 'Integrates with elasticsearch API' do
37
- it 'should perform the API methods' do
38
- expect do
39
- # Index a document
40
- client.index(index: 'test-index', id: '1', body: { title: 'Test' })
41
-
42
- # Refresh the index
43
- client.indices.refresh(index: 'test-index')
44
-
45
- # Search
46
- response = client.search(index: 'test-index', body: { query: { match: { title: 'test' } } })
47
-
48
- expect(response['hits']['total']['value']).to eq 1
49
- expect(response['hits']['hits'][0]['_source']['title']).to eq 'Test'
50
-
51
- # Delete the index
52
- client.indices.delete(index: 'test-index')
53
- end.not_to raise_error
54
- end
55
- end
56
-
57
- context 'Reports the right meta header' do
58
- it 'Reports es service name and gem version' do
59
- headers = client.transport.connections.first.connection.headers
60
- version = Class.new.extend(Elastic::Transport::MetaHeader).send(:client_meta_version, Elasticsearch::VERSION)
61
- expect(headers['x-elastic-client-meta']).to match /^es=#{version}/
62
- end
63
- end
64
- end