弹性搜索json数组

时间:2014-08-06 03:55:33

标签: json elasticsearch

我有一个json文件,我想将json文件加载到弹性搜索中,所以我做了,

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

但它会产生som错误:

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

我的数据是这样的:

[
{
"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"
 }
]

所以请帮我解决这个问题。 顺便说一下,我是Elasticsearch的新手。

1 个答案:

答案 0 :(得分:1)

好的,通过这个你只能索引一个文件(但你的json是数组或文件,这给出了错误)。 如果您需要索引多个文档,请使用bulk api

例如,请查看link.