Error Loading json file on elasticsearch aws

I've just set up an elasticsearch domain using Elastic search service from aws. Now I want to feed it with some json file using: curl -XPOST 'my-aws-domain-here/_bulk/' --data-binary @base_enquete.json according to the documentation here.

My json file looks like the following: [{"INDID": "10040","DATENQ": "29/7/2013","Name": "LANDIS MADAGASCAR SA"}, {"INDID": "10050","DATENQ": "14/8/2013","Name": "MADAFOOD SA","M101P": ""}] which gives me this error:

{"error":"ActionRequestValidationException[Validation Failed: 1: no requests added;]","status":400}

I tried without [ and ] same error!

Note that I already set up access policy to be open to the world for dev stage purpose.

Any help of any kind will be helpful :)

Upvotes: 0

Views: 393

Answers (1)

Vineeth Mohan
Vineeth Mohan

Reputation: 19273

This is because of the wrong format of data. Please go through the documentation here.

Ideally it should be in format -

action_and_meta_data\n
optional_source\n
action_and_meta_data\n
optional_source\n
....
action_and_meta_data\n
optional_source\n

This means that content of the file you are sending should be in following format -

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{"INDID": "10040","DATENQ": "29/7/2013","Name": "LANDIS MADAGASCAR SA"}
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{"INDID": "10050","DATENQ": "14/8/2013","Name": "MADAFOOD SA","M101P": ""}

Upvotes: 2

Related Questions