简体   繁体   English

弹性搜索json数组

[英]Elastic search for json array

I have a json file and I want to load the json file into elastic search so I did, 我有一个json文件,我想将json文件加载到弹性搜索中,所以我做到了,

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. 顺便说一句,我是Elasticsearch的新手。

Ok,By this you only can index a document (But your json is array or documents, which gives error) . 好的,这样您只能索引一个文档(但是您的json是数组或文档,会产生错误)。 If you need to index multiple documents just use bulk api 如果您需要索引多个文档,只需使用批量API

For example look at the link. 例如,查看链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM