Help: Bulk Update doesn't work


(Ivan Ghisleni) #1

Hi to everyone,

I have this problem when I'm trying to to update with the bulk operation:

Command:
curl -XPOST localhost:9200/_bulk?pretty -d '{ "update" : { "_index" : "test", "_type" : "type1", "_id" : "1"} } { "doc": { "field1" : "value2" }}'

Response:
{
"error" : {
"root_cause" : [ {
"type" : "action_request_validation_exception",
"reason" : "Validation Failed: 1: no requests added;"
} ],
"type" : "action_request_validation_exception",
"reason" : "Validation Failed: 1: no requests added;"
},
"status" : 400
}

Index content:

{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "test",
"_type": "type1",
"_id": "3",
"_score": 1,
"_source": {
"field1": "value3"
}
},
{
"_index": "test",
"_type": "type1",
"_id": "1",
"_score": 1,
"_source": {
"field1": "value1"
}
}
]
}
}

If I run the command:
curl -XPOST localhost:9200/test/type1/1 -d '{ "doc": { "field1" : "value2" }}'
it works.

This is my Version:

"version" : {
"number" : "2.1.0",
"build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87",
"build_timestamp" : "2015-11-18T22:40:03Z",
"build_snapshot" : false,
"lucene_version" : "5.3.1"
}

what's wrong??

Ivan


(Christian Dahlqvist) #2

The two JSON documents that make up your bulk request should be on separate lines and this does not seem to be the case.


(Mark Walkom) #3

You will also need a \n at the end of the line.


(Ivan Ghisleni) #4

Thanks for the help
\n saved me
:wink:


(චානක මධුරංග කරුණාරත්න (Chanaka Maduranga)) #5

Thanks!
"/n" worked.


(system) #6