Help: Bulk Update doesn't work

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

1 Like

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

1 Like

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

3 Likes

Thanks for the help
\n saved me
:wink:

1 Like

Thanks!
"/n" worked.

2 Likes