3
4
5
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
32
33
34
|
# File 'lib/goodyear/index.rb', line 3
def store(*args)
document, options = args
id = get_id_from_document(document)
type = get_type_from_document(document)
index = get_index_from_document(document)
document = convert_document_to_json(document)
options ||= {}
params = {}
if options[:percolate]
params[:percolate] = options[:percolate]
params[:percolate] = "*" if params[:percolate] === true
end
params[:parent] = options[:parent] if options[:parent]
params[:routing] = options[:routing] if options[:routing]
params[:replication] = options[:replication] if options[:replication]
params[:version] = options[:version] if options[:version]
params_encoded = params.empty? ? '' : "?#{params.to_param}"
url_with_index = index.blank? ? self.url : self.url.gsub(name, index)
url = id ? "#{url_with_index}/#{type}/#{Utils.escape(id)}#{params_encoded}" : "#{url_with_index}/#{type}/#{params_encoded}"
@response = Configuration.client.post url, document
MultiJson.decode(@response.body)
ensure
curl = %Q|curl -X POST "#{url}" -d '#{document}'|
logged([type, id].join('/'), curl)
end
|