Skip to content

Commit 3bb3e06

Browse files
committed
[API] Generator: Find structure needs NDJSON input option
1 parent 54272e8 commit 3bb3e06

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

elasticsearch-api/utils/thor/generator/endpoint_specifics.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ def bulk_body_helper
170170
SRC
171171
end
172172

173+
def find_structure_body_helper
174+
bulk_body_helper
175+
end
176+
173177
def bulk_doc_helper(info)
174178
<<~SRC
175179
# @option arguments [String|Array] :body #{info}. Array of Strings, Header/Data pairs,

elasticsearch-api/utils/thor/templates/_perform_request.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ when 'mtermvectors'
1414
<%- else -%>
1515
<%= ' '*(@namespace_depth+3) %>body = <%= @spec['body'].nil? ? 'nil' : 'arguments[:body]' %>
1616
<%- end -%>
17-
<%- if ['bulk', 'msearch', 'msearch_template'].include? @method_name -%>
17+
<%- if ['bulk', 'msearch', 'msearch_template', 'find_structure'].include? @method_name -%>
1818
<%= self.send("#{@method_name}_body_helper".to_s) %>
1919
headers.merge!("Content-Type" => "application/x-ndjson")
2020
<%= ' '*(@namespace_depth+4) %>perform_request(method, path, params, payload, headers).body

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/text_structure/find_structure.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ def find_structure(arguments = {})
5757
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
5858

5959
body = arguments[:body]
60-
perform_request(method, path, params, body, headers).body
60+
if body.is_a? Array
61+
payload = Elasticsearch::API::Utils.__bulkify(body)
62+
else
63+
payload = body
64+
end
65+
66+
headers.merge!("Content-Type" => "application/x-ndjson")
67+
perform_request(method, path, params, payload, headers).body
6168
end
6269

6370
# Register this action with its valid params when the module is loaded.

0 commit comments

Comments
 (0)