elasticsearch 8.18.0 → 9.0.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.

Potentially problematic release.


This version of elasticsearch might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffbcb26ce9f617a221824e96f4c0e35d0527421ec96a91bfb23d24505ef40179
4
- data.tar.gz: bbd6ef3916794c4bd36fa01939bf5ae6e655348405afaa5625000be63add8baa
3
+ metadata.gz: 531d7ccecbe543b04dbbc08b84a0e3e01e4cf9833eb54dba10fe3a4560e24a2c
4
+ data.tar.gz: 1a80e1229300f84ea163e0472393f69f53805483d8eeb0c63a1e18f68e9ae846
5
5
  SHA512:
6
- metadata.gz: 742d28e13b8c5ee4c48d8b783e13b0abcc57848f1cf128dbf363b6c11c54aa6882a0421785f60b1f295f547c41abf36663e342b210347e9ff56bc5c363d0575e
7
- data.tar.gz: 94fd5a49a98f22d11feb427f78fd6319a8a856a0bcb8286408243e907d041213cabcacfde04ebb92f42da887d0f152842ec03e3e63304eeb61a1d9d8b42eea34
6
+ metadata.gz: '0946a2468eb4fa0ec9f09fdf349cb977200fc69e76078c7611b596e75be0e4ee8980107117c36f097efdcae1164c15ba489054ab2270712fddfcfc0ea9bcb5e0'
7
+ data.tar.gz: 5bd32a69b2950fe613aa607634569fe099935baaf930f7efefd87eef93ae9773a16be47236fa3998063d542f04a5dadf88e343c97a11e459138c0cddc09fcce4
@@ -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,20 +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.1'
48
50
  s.add_dependency 'elastic-transport', '~> 8.3'
49
- s.add_dependency 'elasticsearch-api', '8.18.0'
50
51
 
51
52
  s.add_development_dependency 'base64'
52
53
  s.add_development_dependency 'bundler'
@@ -16,5 +16,5 @@
16
16
  # under the License.
17
17
 
18
18
  module Elasticsearch
19
- VERSION = '8.18.0'.freeze
19
+ VERSION = '9.0.1'.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
@@ -51,6 +52,7 @@ module Elasticsearch
51
52
  api_key(arguments) if arguments[:api_key]
52
53
  setup_cloud(arguments) if arguments[:cloud_id]
53
54
  set_user_agent!(arguments) unless sent_user_agent?(arguments)
55
+ set_content_type!(arguments)
54
56
  @transport = Elastic::Transport::Client.new(arguments, &block)
55
57
  end
56
58
 
@@ -65,10 +67,10 @@ module Elasticsearch
65
67
  opaque_id = @opaque_id_prefix ? "#{@opaque_id_prefix}#{opaque_id}" : opaque_id
66
68
  args[4] = headers.merge('X-Opaque-Id' => opaque_id)
67
69
  end
68
- unless @verified
69
- verify_elasticsearch(*args, &block)
70
- else
70
+ if @verified
71
71
  @transport.perform_request(*args, &block)
72
+ else
73
+ verify_elasticsearch(*args, &block)
72
74
  end
73
75
  else
74
76
  @transport.send(name, *args, &block)
@@ -101,6 +103,7 @@ module Elasticsearch
101
103
  raise e
102
104
  end
103
105
  raise Elasticsearch::UnsupportedProductError unless response.headers['x-elastic-product'] == 'Elasticsearch'
106
+
104
107
  @verified = true
105
108
  response
106
109
  end
@@ -173,9 +176,21 @@ module Elasticsearch
173
176
  if RbConfig::CONFIG && RbConfig::CONFIG['host_os']
174
177
  user_agent << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}"
175
178
  end
179
+ set_header({ user_agent: user_agent.join('; ') }, arguments)
180
+ end
181
+
182
+ def set_content_type!(arguments)
183
+ headers = {
184
+ 'content-type' => 'application/vnd.elasticsearch+json; compatible-with=9',
185
+ 'accept' => 'application/vnd.elasticsearch+json; compatible-with=9'
186
+ }
187
+ set_header(headers, arguments)
188
+ end
189
+
190
+ def set_header(header, arguments)
176
191
  arguments[:transport_options] ||= {}
177
192
  arguments[:transport_options][:headers] ||= {}
178
- arguments[:transport_options][:headers].merge!({ user_agent: user_agent.join('; ')})
193
+ arguments[:transport_options][:headers].merge!(header)
179
194
  end
180
195
  end
181
196
 
metadata CHANGED
@@ -1,42 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.18.0
4
+ version: 9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic Client Library Maintainers
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-15 00:00:00.000000000 Z
10
+ date: 2025-04-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: elastic-transport
13
+ name: elasticsearch-api
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: '8.3'
18
+ version: 9.0.1
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
- - - "~>"
23
+ - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: '8.3'
25
+ version: 9.0.1
26
26
  - !ruby/object:Gem::Dependency
27
- name: elasticsearch-api
27
+ name: elastic-transport
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - '='
30
+ - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 8.18.0
32
+ version: '8.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '='
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 8.18.0
39
+ version: '8.3'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: base64
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -204,10 +204,8 @@ extra_rdoc_files:
204
204
  - LICENSE.txt
205
205
  files:
206
206
  - ".gitignore"
207
- - Gemfile
208
207
  - LICENSE.txt
209
208
  - README.md
210
- - Rakefile
211
209
  - bin/elastic_ruby_console
212
210
  - elasticsearch.gemspec
213
211
  - lib/elasticsearch-ruby.rb
@@ -216,22 +214,6 @@ files:
216
214
  - lib/elasticsearch/helpers/esql_helper.rb
217
215
  - lib/elasticsearch/helpers/scroll_helper.rb
218
216
  - lib/elasticsearch/version.rb
219
- - spec/integration/characters_escaping_spec.rb
220
- - spec/integration/client_integration_spec.rb
221
- - spec/integration/helpers/bulk_helper_spec.rb
222
- - spec/integration/helpers/esql_helper_spec.rb
223
- - spec/integration/helpers/helpers_spec_helper.rb
224
- - spec/integration/helpers/scroll_helper_spec.rb
225
- - spec/integration/opentelemetry_spec.rb
226
- - spec/spec_helper.rb
227
- - spec/unit/api_key_spec.rb
228
- - spec/unit/cloud_credentials_spec.rb
229
- - spec/unit/custom_transport_implementation_spec.rb
230
- - spec/unit/elasticsearch_product_validation_spec.rb
231
- - spec/unit/headers_spec.rb
232
- - spec/unit/opaque_id_spec.rb
233
- - spec/unit/user_agent_spec.rb
234
- - spec/unit/wrapper_gem_spec.rb
235
217
  homepage: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html
236
218
  licenses:
237
219
  - Apache-2.0
@@ -248,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
248
230
  requirements:
249
231
  - - ">="
250
232
  - !ruby/object:Gem::Version
251
- version: '2.5'
233
+ version: '2.6'
252
234
  required_rubygems_version: !ruby/object:Gem::Requirement
253
235
  requirements:
254
236
  - - ">="
@@ -258,20 +240,4 @@ requirements: []
258
240
  rubygems_version: 3.6.2
259
241
  specification_version: 4
260
242
  summary: Ruby integrations for Elasticsearch
261
- test_files:
262
- - spec/integration/characters_escaping_spec.rb
263
- - spec/integration/client_integration_spec.rb
264
- - spec/integration/helpers/bulk_helper_spec.rb
265
- - spec/integration/helpers/esql_helper_spec.rb
266
- - spec/integration/helpers/helpers_spec_helper.rb
267
- - spec/integration/helpers/scroll_helper_spec.rb
268
- - spec/integration/opentelemetry_spec.rb
269
- - spec/spec_helper.rb
270
- - spec/unit/api_key_spec.rb
271
- - spec/unit/cloud_credentials_spec.rb
272
- - spec/unit/custom_transport_implementation_spec.rb
273
- - spec/unit/elasticsearch_product_validation_spec.rb
274
- - spec/unit/headers_spec.rb
275
- - spec/unit/opaque_id_spec.rb
276
- - spec/unit/user_agent_spec.rb
277
- - 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