6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/model-msearch.rb', line 6
def msearch!(payload)
body = payload.map do |source|
= source.search.definition.slice(*MSEARCH_VALID_HEADERS)
__definition = source.search.definition.except(*MSEARCH_VALID_HEADERS)
__body = __definition.delete(:body)
[, __definition.merge(__body)]
end
body.flatten!
results = client.msearch(body: body)
responses = []
results["responses"].each_with_index do |result, i|
r = Response::Response.new(payload[i].klass, payload[i].search)
r.instance_variable_set(:@response, Hashie::Mash.new(result))
responses.push r
end
responses
end
|