How to post multiple records to same index via curl


(Kenneth) #1

Hi,

I am trying to write multiple records to the same index using curl. I can write one entry successfully, but I get a syntax error saying , unexpected when I try and add the second one. I found a posting which says I have to use the _bulk endpoint, but when I try that I get "No handler found for uri [/composer/well/1/_bulk] and method [PUT]"

Is there an easy way to write multiple records to the same index using curl?


(David Pilato) #2

Docs says:

curl -XPOST 'localhost:9200/_bulk?pretty' -H 'Content-Type: application/json' -d'
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "index1", "_retry_on_conflict" : 3} }
{ "doc" : {"field" : "value"} }
{ "update" : { "_id" : "0", "_type" : "type1", "_index" : "index1", "_retry_on_conflict" : 3} }
{ "script" : { "inline": "ctx._source.counter += params.param1", "lang" : "painless", "params" : {"param1" : 1}}, "upsert" : {"counter" : 1}}
{ "update" : {"_id" : "2", "_type" : "type1", "_index" : "index1", "_retry_on_conflict" : 3} }
{ "doc" : {"field" : "value"}, "doc_as_upsert" : true }
{ "update" : {"_id" : "3", "_type" : "type1", "_index" : "index1", "_source" : true} }
{ "doc" : {"field" : "value"} }
{ "update" : {"_id" : "4", "_type" : "type1", "_index" : "index1"} }
{ "doc" : {"field" : "value"}, "_source": true}
'

So basically here try with:

POST /composer/well/_bulk

(Kenneth) #3

Schlumberger-Private
Thanks for that David,

Very useful

Regards,
Kenneth


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.