Elastic search Bulk Post testing


(KMG) #1

Getting below error when doing testing on my local environment. Please someone help me where I did the mistake.

curl -XPOST 'localhost:9014/customer/external/_bulk?pretty' -d '
{"index":{{"_id":"15"}}
{"account_number":995,"balance":21153,"firstname":"Phelps","lastname":"Parrish","age":25,"gender":"M","address":"666 Miller Place","employer":"Pearlessa","email":"phelpsparrish@pearlessa.com","city":"Brecon","state":"ME"}'
{
"error" : "JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@543fb89e; line: 1, column: 12]]",
"status" : 500
}


(Colin Goodheart-Smithe) #2

This error is becuase the request contains invalid JSON. Remove the extra { before "_id" and the error should be resolved.


(David Pilato) #3

Adding to this that you MUST add a line return after last bulk.


(KMG) #4

Please give some example from the above data. As I tried by removing { from the command, now it failed with Validation. Then I checked with json-validator, it show some error with same { brace.

I just downloaded the json that mentioned on the elastic document page.

current error :

curl -XPOST 'localhost:9014/customer/external/_bulk?pretty' -d '
{"index":{"_id":"15"}}
{"account_number":995,"balance":21153,"firstname":"Phelps","lastname":"Parrish","age":25,"gender":"M","address":"666 Miller Place","employer":"Pearlessa","email":"phelpsparrish@pearlessa.com","city":"Brecon","state":"ME"}'
{
"error" : "ActionRequestValidationException[Validation Failed: 1: no requests added;]",
"status" : 400
}


(Colin Goodheart-Smithe) #5

You need to add a new line to the end of the request as mentioned by @dadoonet.

curl -XPOST 'localhost:9014/customer/external/_bulk?pretty' -d '
{"index":{"_id":"15"}}
{"account_number":995,"balance":21153,"firstname":"Phelps","lastname":"Parrish","age":25,"gender":"M","address":"666 Miller Place","employer":"Pearlessa","email":"phelpsparrish@pearlessa.com","city":"Brecon","state":"ME"}
'

(KMG) #6

Great ! Thank You . Its worked. :smile:


(system) #7