Hi,
I am having troubles executing bulk operations via curl if the bulk command
sequence is in file.
The following works fine:
curl -XDELETE 'http://localhost:9200/test/?pretty=1'
curl -XPUT 'http://localhost:9200/test/?pretty=1' -d '{ index : {
number_of_shards : 3, number_of_replicas : 0 }}'
curl -XPUT 'http://localhost:9200/_bulk' -d '
{ "create" : {"_index":"test","_type":"one","_id":"1"} }
{"name":"01","category":"01","subcategory":"01" }
{ "create" : {"_index":"test","_type":"one","_id":"2"} }
{"name":"02","category":"01","subcategory":"02" }
{ "create" : {"_index":"test","_type":"one","_id":"3"} }
{"name":"03","category":"01","subcategory":"02" }
{ "create" : {"_index":"test","_type":"one","_id":"4"} }
{"name":"04","category":"02","subcategory":"01" }
{ "create" : {"_index":"test","_type":"one","_id":"5"} }
{"name":"05","category":"02","subcategory":"01" }
{ "create" : {"_index":"test","_type":"one","_id":"6"} }
{"name":"06","category":"01","subcategory":"02" }
'
gives me the following response:
{
"ok" : true,
"acknowledged" : true
}
{
"ok" : true,
"acknowledged" : true
}
{"items":[{"create":{"_index":"test","_type":"one","_id":"1","ok":true}},{"create":{"_index":"test","_type":"one","_id":"2","ok":true}},{"create":{"_index":"test","_type":"one","_id":"3","ok":true}},{"create":{"_index":"test","_type":"one","_id":"4","ok":true}},{"create":{"_index":"test","_type":"one","_id":"5","ok":true}},{"create":{"_index":"test","_type":"one","_id":"6","ok":true}}]}
but if I put bulk operations into a file and run
curl -XPUT 'http://localhost:9200/_bulk' -d @bulk.data
then it gives me:
{"error":"ActionRequestValidationException[Validation Failed: 1: no requests
added]"}
Content of the file is the following:
$ cat bulk.data
{ "create" : {"_index":"test","_type":"one","_id":"1"} }
{"name":"01","category":"01","subcategory":"01" }
{ "create" : {"_index":"test","_type":"one","_id":"2"} }
{"name":"02","category":"01","subcategory":"02" }
{ "create" : {"_index":"test","_type":"one","_id":"3"} }
{"name":"03","category":"01","subcategory":"02" }
{ "create" : {"_index":"test","_type":"one","_id":"4"} }
{"name":"04","category":"02","subcategory":"01" }
{ "create" : {"_index":"test","_type":"one","_id":"5"} }
{"name":"05","category":"02","subcategory":"01" }
{ "create" : {"_index":"test","_type":"one","_id":"6"} }
{"name":"06","category":"01","subcategory":"02" }
$
(note the extra new line at the end of the file data)
Regards,
Lukas