18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/embulk/output/azuresearch/client.rb', line 18
def add_documents(index_name, documents, merge=true)
raise ConfigError, 'no index_name' if index_name.empty?
raise ConfigError, 'no documents' if documents.empty?
action = merge ? 'mergeOrUpload' : 'upload'
for document in documents
document['@search.action'] = action
end
req_body = { :value => documents }.to_json
res = RestClient.post(
"#{@api_url}/indexes/#{index_name}/docs/index?api-version=#{@api_version}",
req_body,
)
res
end
|