0

I have a json file and I want to load the json file into elastic search so I did,

curl -XPOST 'http://localhost:9200/datas/data/1' -d @rosia_data.json 

but it produce som error as:

{"error":"MapperParsingException[Malformed content, must start withno bject]","status":400}

My data is something like this:

[
{
"sr":"Krishna Chaudhary", 
"inventory":"Vector Plus - 2`S",
"packaing_unit":"pcs",
"shopname":"D&b Store",
"shoproute":"RCT Market",
"quantity":12,
"order_id":21745,
"distributor_name":"New Horizon Distributors Itahari",
"distributor_id":13,
"order_date":"2014-06-01"
  },
  {
 "sr":"Krishna Chaudhary",
  "inventory":"Vector Plus - 4`S",
  "packaing_unit":"pcs",
  "shopname":"D&b Store",
  "shoproute":"RCT Market",
  "quantity":12,
  "order_id":21746,
  "distributor_name":"New Horizon Distributors Itahari",
  "distributor_id":13,
  "order_date":"2014-06-01"
 },
 {
 "sr":"Khagendra Pokhrel",
"inventory":"Vector Plus - 4`S",
"packaing_unit":"pcs",
"shopname":"Samita Cosmetic",
"shoproute":"Pathri",
"quantity":12,
"order_id":21762,
"distributor_name":"Horizon Distributors Damak",
"distributor_id":14,
"order_date":"2014-06-01"
 }
]

so please help me to solve this problem. BTW I am new to Elasticsearch.

1
  • Can you show @rosia_data.json content Commented Aug 6, 2014 at 3:56

1 Answer 1

1

Ok,By this you only can index a document (But your json is array or documents, which gives error) . If you need to index multiple documents just use bulk api

For example look at the link.

Sign up to request clarification or add additional context in comments.

5 Comments

how to load the data with bulk api. Can you give a example?
I am getting this error: { "error":"ActionRequestValidationException[Validation Failed: 1: no requests added;]","status":500}
make sure, you only don't have linebreaks in a json , look at my gist. it will work
so my .json file is 3mb and do i have to manually include {"index" : {"_index" : "datas" , "_type" : "data" , "_id" : 1}} in each inner array of json file.
You should just make structure as i've written (yes append the string, and don't use as array), or you should write a script(probably using python) .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.