Elastic bulk API Multiple docs with single action

I'm trying to index multiple docs on a single action (index), is there any way to avoid repeating the action with each document in the input.

curl -XPOST 'https://localhost:9200/myindex/mytype/_bulk?pretty' -H 'Content-Type: application/json' -d'
{"index" : {}}
{ "field1" : "value1","field2": "value2"}
{"index" : {}}
{ "field1" : "value12","field2": "value22"}
'
In this case , is there any way to avoid repeating {"index" : {}} before each document ?

I do not see a way to avoid repeating the {"index" : {}} before each document, but I made it easier to do so by using the find and replace on my notepad.

For example: Mytest.txt

{ "field1" : "value1","field2": "value2"}
{ "field1" : "value12","field2": "value22"}
.....
....

Find { "field1" :
Replace {"index" : {}}
{ "field1" :

Now in my Mytest.txt I see

{"index" : {}}
{ "field1" : "value1","field2": "value2"}
{"index" : {}}
{ "field1" : "value12","field2": "value22"}
.....
.....

curl -k -XPOST 'https://localhost:9200/myindex/mytype/_bulk?pretty' --data-binary "@Mytest.txt" -H 'Content-Type: application/json'

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