elasticsearch 8.13.0 → 8.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/elasticsearch.gemspec +2 -2
- data/lib/elasticsearch/helpers/bulk_helper.rb +3 -1
- data/lib/elasticsearch/helpers/esql_helper.rb +2 -1
- data/lib/elasticsearch/version.rb +1 -1
- data/spec/integration/characters_escaping_spec.rb +4 -2
- data/spec/integration/client_integration_spec.rb +1 -0
- data/spec/integration/helpers/bulk_helper_spec.rb +5 -0
- data/spec/integration/helpers/esql_helper_spec.rb +26 -2
- data/spec/integration/opentelemetry_spec.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e91dd04380e4aec75fe156542e45de7cae72e84fc62fb79fd31b3b1dac134be3
|
4
|
+
data.tar.gz: 01ff5e017053fcbb9177d6bac006857872e568a0bdf09b0d1e24a20b1731bc28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 353baeb8c69b35714acd44ca1d94c87ca4c0a895482a874061ea523b41ff27cfd46464e49a014b584ab1a68a3dd8a0d2176d69a883599679f17dc8a4fa1acf54
|
7
|
+
data.tar.gz: b8755ed3e109e62dc1611c64f80e3833d7fe7e8cf07623bd7b718d345546921eb67465eac4b537d07b3ae2ead4301ccd5b728cc323dd07c5a43ef3e0b80482eb
|
data/elasticsearch.gemspec
CHANGED
@@ -46,8 +46,8 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.required_ruby_version = '>= 2.5'
|
47
47
|
|
48
48
|
s.add_dependency 'elastic-transport', '~> 8.3'
|
49
|
-
s.add_dependency 'elasticsearch-api', '8.
|
50
|
-
|
49
|
+
s.add_dependency 'elasticsearch-api', '8.15.0'
|
50
|
+
|
51
51
|
s.add_development_dependency 'base64'
|
52
52
|
s.add_development_dependency 'bundler'
|
53
53
|
s.add_development_dependency 'debug' unless defined?(JRUBY_VERSION)
|
@@ -48,7 +48,9 @@ module Elasticsearch
|
|
48
48
|
def ingest(docs, params = {}, body = {}, &block)
|
49
49
|
ingest_docs = docs.map { |doc| { index: { _index: @index, data: doc} } }
|
50
50
|
if (slice = params.delete(:slice))
|
51
|
-
ingest_docs.each_slice(slice)
|
51
|
+
ingest_docs.each_slice(slice) do |items|
|
52
|
+
ingest(items.map { |item| item[:index][:data] }, params, &block)
|
53
|
+
end
|
52
54
|
else
|
53
55
|
bulk_request(ingest_docs, params, &block)
|
54
56
|
end
|
@@ -57,11 +57,12 @@ module Elasticsearch
|
|
57
57
|
#
|
58
58
|
def self.query(client, query, params = {}, parser: {})
|
59
59
|
response = client.esql.query({ body: { query: query }, format: 'json' }.merge(params))
|
60
|
+
|
60
61
|
columns = response['columns']
|
61
62
|
response['values'].map do |value|
|
62
63
|
(value.length - 1).downto(0).map do |index|
|
63
64
|
key = columns[index]['name']
|
64
|
-
value[index] = parser[key].call
|
65
|
+
value[index] = parser[key].call(value[index]) if value[index] && parser[key]
|
65
66
|
{ key => value[index] }
|
66
67
|
end.reduce({}, :merge)
|
67
68
|
end
|
@@ -14,10 +14,12 @@
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
15
15
|
# specific language governing permissions and limitations
|
16
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
17
|
|
20
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/
|
21
23
|
|
22
24
|
context 'Elasticsearch client' do
|
23
25
|
let(:client) do
|
@@ -21,6 +21,7 @@ require 'tempfile'
|
|
21
21
|
context 'Elasticsearch client helpers' do
|
22
22
|
context 'Bulk helper' do
|
23
23
|
let(:index) { 'bulk_animals' }
|
24
|
+
let(:index_slice) { 'bulk_animals_slice' }
|
24
25
|
let(:params) { { refresh: 'wait_for' } }
|
25
26
|
let(:bulk_helper) { Elasticsearch::Helpers::BulkHelper.new(client, index, params) }
|
26
27
|
let(:docs) do
|
@@ -40,6 +41,7 @@ context 'Elasticsearch client helpers' do
|
|
40
41
|
|
41
42
|
after do
|
42
43
|
client.indices.delete(index: index, ignore: 404)
|
44
|
+
client.indices.delete(index: index_slice, ignore: 404)
|
43
45
|
end
|
44
46
|
|
45
47
|
it 'Ingests documents' do
|
@@ -76,10 +78,13 @@ context 'Elasticsearch client helpers' do
|
|
76
78
|
|
77
79
|
it 'Ingests documents and yields response and docs' do
|
78
80
|
slice = 2
|
81
|
+
bulk_helper = Elasticsearch::Helpers::BulkHelper.new(client, index_slice, params)
|
79
82
|
response = bulk_helper.ingest(docs, {slice: slice}) do |response, docs|
|
80
83
|
expect(response).to be_an_instance_of Elasticsearch::API::Response
|
81
84
|
expect(docs.count).to eq slice
|
82
85
|
end
|
86
|
+
response = client.search(index: index_slice, size: 200)
|
87
|
+
expect(response['hits']['hits'].map { |a| a['_source'].transform_keys(&:to_sym) }).to eq docs
|
83
88
|
end
|
84
89
|
|
85
90
|
context 'JSON File helper' do
|
@@ -16,6 +16,7 @@
|
|
16
16
|
# under the License.
|
17
17
|
require_relative 'helpers_spec_helper'
|
18
18
|
require 'elasticsearch/helpers/esql_helper'
|
19
|
+
require 'ipaddr'
|
19
20
|
|
20
21
|
context 'Elasticsearch client helpers' do
|
21
22
|
let(:index) { 'esql_helper_test' }
|
@@ -76,8 +77,6 @@ context 'Elasticsearch client helpers' do
|
|
76
77
|
end
|
77
78
|
|
78
79
|
it 'parses iterated objects when procs are passed in' do
|
79
|
-
require 'ipaddr'
|
80
|
-
|
81
80
|
parser = {
|
82
81
|
'@timestamp' => Proc.new { |t| DateTime.parse(t) },
|
83
82
|
'client.ip' => Proc.new { |i| IPAddr.new(i) },
|
@@ -91,4 +90,29 @@ context 'Elasticsearch client helpers' do
|
|
91
90
|
expect(r['event.duration']).to be_a String
|
92
91
|
end
|
93
92
|
end
|
93
|
+
|
94
|
+
it 'parser does not error when value is nil, leaves nil' do
|
95
|
+
client.index(
|
96
|
+
index: index,
|
97
|
+
body: {
|
98
|
+
'@timestamp' => nil,
|
99
|
+
'client.ip' => nil,
|
100
|
+
message: 'Connected to 10.1.0.1',
|
101
|
+
'event.duration' => 1756465
|
102
|
+
},
|
103
|
+
refresh: true
|
104
|
+
)
|
105
|
+
parser = {
|
106
|
+
'@timestamp' => Proc.new { |t| DateTime.parse(t) },
|
107
|
+
'client.ip' => Proc.new { |i| IPAddr.new(i) },
|
108
|
+
'event.duration' => Proc.new { |d| d.to_s }
|
109
|
+
}
|
110
|
+
response = esql_helper.query(client, query, parser: parser)
|
111
|
+
response.each do |r|
|
112
|
+
expect [DateTime, NilClass].include?(r['@timestamp'].class)
|
113
|
+
expect [IPAddr, NilClass].include?(r['client.ip'].class)
|
114
|
+
expect(r['message']).to be_a String
|
115
|
+
expect(r['event.duration']).to be_a String
|
116
|
+
end
|
117
|
+
end
|
94
118
|
end
|
@@ -36,12 +36,12 @@ if ENV['TEST_WITH_OTEL'] == 'true'
|
|
36
36
|
end
|
37
37
|
|
38
38
|
after do
|
39
|
-
|
39
|
+
client.delete(index: 'myindex', id: 1); rescue
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'when a request is instrumented' do
|
43
43
|
it 'sets the span name to the endpoint id' do
|
44
|
-
client.search(body: { query: { match: {a: 1} } })
|
44
|
+
client.search(body: { query: { match: { a: 1 } } })
|
45
45
|
expect(span.name).to eq 'search'
|
46
46
|
end
|
47
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic Client Library Maintainers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elastic-transport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 8.
|
33
|
+
version: 8.15.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 8.
|
40
|
+
version: 8.15.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: base64
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
257
|
- !ruby/object:Gem::Version
|
258
258
|
version: '0'
|
259
259
|
requirements: []
|
260
|
-
rubygems_version: 3.5.
|
260
|
+
rubygems_version: 3.5.11
|
261
261
|
signing_key:
|
262
262
|
specification_version: 4
|
263
263
|
summary: Ruby integrations for Elasticsearch
|