elasticsearch 7.13.3 → 8.14.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 +4 -4
- data/Gemfile +8 -6
- data/README.md +71 -33
- data/Rakefile +15 -20
- data/bin/elastic_ruby_console +2 -18
- data/elasticsearch.gemspec +24 -35
- data/lib/elasticsearch/helpers/bulk_helper.rb +129 -0
- data/lib/elasticsearch/helpers/esql_helper.rb +72 -0
- data/lib/elasticsearch/helpers/scroll_helper.rb +95 -0
- data/lib/elasticsearch/version.rb +1 -1
- data/lib/elasticsearch.rb +167 -7
- data/spec/integration/characters_escaping_spec.rb +94 -0
- data/spec/integration/client_integration_spec.rb +64 -0
- data/spec/integration/helpers/bulk_helper_spec.rb +206 -0
- data/spec/integration/helpers/esql_helper_spec.rb +118 -0
- data/spec/integration/helpers/helpers_spec_helper.rb +29 -0
- data/spec/integration/helpers/scroll_helper_spec.rb +81 -0
- data/spec/integration/opentelemetry_spec.rb +55 -0
- data/spec/spec_helper.rb +43 -0
- data/spec/unit/api_key_spec.rb +138 -0
- data/spec/unit/cloud_credentials_spec.rb +167 -0
- data/spec/unit/custom_transport_implementation_spec.rb +43 -0
- data/spec/unit/elasticsearch_product_validation_spec.rb +148 -0
- data/spec/unit/headers_spec.rb +55 -0
- data/spec/unit/opaque_id_spec.rb +48 -0
- data/spec/unit/user_agent_spec.rb +69 -0
- data/{test/unit/wrapper_gem_test.rb → spec/unit/wrapper_gem_spec.rb} +11 -21
- metadata +64 -111
- data/test/integration/client_integration_test.rb +0 -80
- data/test/test_helper.rb +0 -115
- /data/{LICENSE → LICENSE.txt} +0 -0
@@ -1,80 +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 'test_helper'
|
19
|
-
require 'logger'
|
20
|
-
|
21
|
-
module Elasticsearch
|
22
|
-
module Test
|
23
|
-
class ClientIntegrationTest < Elasticsearch::Test::IntegrationTestCase
|
24
|
-
startup do
|
25
|
-
Elasticsearch::Extensions::Test::Cluster.start(number_of_nodes: 2) if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?(number_of_nodes: 2)
|
26
|
-
end
|
27
|
-
|
28
|
-
shutdown do
|
29
|
-
Elasticsearch::Extensions::Test::Cluster.stop(number_of_nodes: 2) if ENV['SERVER'] and Elasticsearch::Extensions::Test::Cluster.running?(number_of_nodes: 2)
|
30
|
-
end
|
31
|
-
|
32
|
-
context "Elasticsearch client" do
|
33
|
-
setup do
|
34
|
-
system "curl -X DELETE http://#{TEST_HOST}:#{TEST_PORT}/_all > /dev/null 2>&1"
|
35
|
-
|
36
|
-
@logger = Logger.new(STDERR)
|
37
|
-
@logger.formatter = proc do |severity, datetime, progname, msg|
|
38
|
-
color = case severity
|
39
|
-
when /INFO/ then :green
|
40
|
-
when /ERROR|WARN|FATAL/ then :red
|
41
|
-
when /DEBUG/ then :cyan
|
42
|
-
else :white
|
43
|
-
end
|
44
|
-
ANSI.ansi(severity[0] + ' ', color, :faint) + ANSI.ansi(msg, :white, :faint) + "\n"
|
45
|
-
end
|
46
|
-
|
47
|
-
@client = Elasticsearch::Client.new host: "#{TEST_HOST}:#{TEST_PORT}", logger: (ENV['QUIET'] ? nil : @logger)
|
48
|
-
end
|
49
|
-
|
50
|
-
should "perform the API methods" do
|
51
|
-
assert_nothing_raised do
|
52
|
-
# Index a document
|
53
|
-
#
|
54
|
-
@client.index index: 'test-index', type: 'test-type', id: '1', body: { title: 'Test' }
|
55
|
-
|
56
|
-
# Refresh the index
|
57
|
-
#
|
58
|
-
@client.indices.refresh index: 'test-index'
|
59
|
-
|
60
|
-
# Search
|
61
|
-
#
|
62
|
-
response = @client.search index: 'test-index', body: { query: { match: { title: 'test' } } }
|
63
|
-
|
64
|
-
assert_equal 1, response['hits']['total']['value']
|
65
|
-
assert_equal 'Test', response['hits']['hits'][0]['_source']['title']
|
66
|
-
|
67
|
-
# Delete the index
|
68
|
-
#
|
69
|
-
@client.indices.delete index: 'test-index'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
should 'report the right meta header' do
|
74
|
-
headers = @client.transport.connections.first.connection.headers
|
75
|
-
assert_match /^es=#{Elasticsearch::VERSION}/, headers['x-elastic-client-meta']
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,115 +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
|
-
ELASTICSEARCH_HOSTS = if hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS']
|
19
|
-
hosts.split(',').map do |host|
|
20
|
-
/(http\:\/\/)?(\S+)/.match(host)[2]
|
21
|
-
end
|
22
|
-
end.freeze
|
23
|
-
|
24
|
-
TEST_HOST, TEST_PORT = ELASTICSEARCH_HOSTS.first.split(':') if ELASTICSEARCH_HOSTS
|
25
|
-
|
26
|
-
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
27
|
-
JRUBY = defined?(JRUBY_VERSION)
|
28
|
-
|
29
|
-
if RUBY_1_8 and not ENV['BUNDLE_GEMFILE']
|
30
|
-
require 'rubygems'
|
31
|
-
gem 'test-unit'
|
32
|
-
end
|
33
|
-
|
34
|
-
if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
|
35
|
-
require 'simplecov'
|
36
|
-
SimpleCov.start { add_filter "/test|test_/" }
|
37
|
-
end
|
38
|
-
|
39
|
-
if ENV['CI'] && !RUBY_1_8
|
40
|
-
require 'simplecov'
|
41
|
-
require 'simplecov-rcov'
|
42
|
-
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
43
|
-
SimpleCov.start { add_filter "/test|test_" }
|
44
|
-
end
|
45
|
-
|
46
|
-
# Register `at_exit` handler for integration tests shutdown.
|
47
|
-
# MUST be called before requiring `test/unit`.
|
48
|
-
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
49
|
-
at_exit { Elasticsearch::Test::IntegrationTestCase.__run_at_exit_hooks }
|
50
|
-
end
|
51
|
-
|
52
|
-
require 'test/unit' if RUBY_1_8
|
53
|
-
|
54
|
-
require 'minitest/autorun'
|
55
|
-
require 'minitest/reporters'
|
56
|
-
require 'shoulda/context'
|
57
|
-
require 'mocha/minitest'
|
58
|
-
|
59
|
-
require 'require-prof' if ENV["REQUIRE_PROF"]
|
60
|
-
require 'elasticsearch'
|
61
|
-
RequireProf.print_timing_infos if ENV["REQUIRE_PROF"]
|
62
|
-
|
63
|
-
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
64
|
-
require 'elasticsearch/extensions/test/cluster'
|
65
|
-
require 'elasticsearch/extensions/test/startup_shutdown'
|
66
|
-
require 'elasticsearch/extensions/test/profiling' unless JRUBY
|
67
|
-
end
|
68
|
-
|
69
|
-
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
70
|
-
|
71
|
-
module Minitest
|
72
|
-
module Assertions
|
73
|
-
def assert_nothing_raised(*args)
|
74
|
-
begin
|
75
|
-
line = __LINE__
|
76
|
-
yield
|
77
|
-
rescue RuntimeError => e
|
78
|
-
raise MiniTest::Assertion, "Exception raised:\n<#{e.class}>", e.backtrace
|
79
|
-
end
|
80
|
-
true
|
81
|
-
end
|
82
|
-
|
83
|
-
def assert_not_nil(object, msg=nil)
|
84
|
-
msg = message(msg) { "<#{object.inspect}> expected to not be nil" }
|
85
|
-
assert !object.nil?, msg
|
86
|
-
end
|
87
|
-
|
88
|
-
def assert_block(*msgs)
|
89
|
-
assert yield, *msgs
|
90
|
-
end
|
91
|
-
|
92
|
-
alias :assert_raise :assert_raises
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
module Elasticsearch
|
97
|
-
module Test
|
98
|
-
class IntegrationTestCase < ::Minitest::Test
|
99
|
-
extend Elasticsearch::Extensions::Test::StartupShutdown
|
100
|
-
|
101
|
-
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
|
102
|
-
context "IntegrationTest" do; should "noop on Ruby 1.8" do; end; end if RUBY_1_8
|
103
|
-
end if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
104
|
-
end
|
105
|
-
|
106
|
-
module Test
|
107
|
-
class ProfilingTest < ::Minitest::Test
|
108
|
-
extend Elasticsearch::Extensions::Test::StartupShutdown
|
109
|
-
extend Elasticsearch::Extensions::Test::Profiling
|
110
|
-
|
111
|
-
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
|
112
|
-
context "IntegrationTest" do; should "noop on Ruby 1.8" do; end; end if RUBY_1_8
|
113
|
-
end unless RUBY_1_8 || JRUBY
|
114
|
-
end
|
115
|
-
end
|
/data/{LICENSE → LICENSE.txt}
RENAMED
File without changes
|