deepak
deepak

Reputation: 253

Elastic search for json array

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.

Upvotes: 0

Views: 3906

Answers (1)

progrrammer
progrrammer

Reputation: 4489

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.

Upvotes: 1

Related Questions