Skip to content

Commit 731f582

Browse files
committed
[Gem] ESQL version parameter is now mandatory
This updates the ESQL query helper to include a default version if one is not passed as a parameter. The specification has not been updated yet apparently, so there are no changes in the code generation.
1 parent 9913e3f commit 731f582

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

elasticsearch/lib/elasticsearch/helpers/esql_helper.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
module Elasticsearch
1919
module Helpers
2020
# Elasticsearch Client Helper for the ES|QL API
21+
# This functionality is Experimental and may be changed or removed
22+
# completely in a future release. Elastic will take a best effort approach
23+
# to fix any issues, but experimental features are not subject to the
24+
# support SLA of official GA features.
2125
#
2226
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html
2327
#
@@ -56,7 +60,9 @@ module ESQLHelper
5660
# @see https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/Helpers.html#_esql_helper
5761
#
5862
def self.query(client, query, params = {}, parser: {})
59-
response = client.esql.query({ body: { query: query }, format: 'json' }.merge(params))
63+
request = build_request(query, params)
64+
response = client.esql.query(request)
65+
6066
columns = response['columns']
6167
response['values'].map do |value|
6268
(value.length - 1).downto(0).map do |index|
@@ -66,6 +72,15 @@ def self.query(client, query, params = {}, parser: {})
6672
end.reduce({}, :merge)
6773
end
6874
end
75+
76+
def self.build_request(query, params)
77+
{
78+
body: {
79+
query: query,
80+
version: params.delete(:version) || '2024.04.01' },
81+
format: 'json'
82+
}.merge(params)
83+
end
6984
end
7085
end
7186
end

0 commit comments

Comments
 (0)