如何使用curl在elasticsearch服务器上上传批量json数据?

时间:2018-02-09 06:37:46

标签: elasticsearch

我使用的是ES版本6.1.3。 我正在尝试使用Windows 7上的curl cmd上传批量的json数据 这是我的cmd:

bool percent_less_than(const student_info &a, const student_info &b) {
    return a.percent < b.percent;
}

我为它尝试了另一个cmd

curl -H "Content-Type:application/json" -XPOST "http://localhost:9200/fooditems/item/_bulk?pretty" --data-binary @food_items.json

这是我的food_items.json的样本数据

curl -H "Content-Type:application/x-ndjson" -XPOST "http://localhost:9200/fooditems/item/_bulk?pretty" --data-binary @food_items.json

curl -XPOST "http://localhost:9200/fooditems/item/_bulk?pretty" --data-binary @food_items.json

我通过Kibana提供的数据映射为 -

> {"index":{"_index":"fooditems","_type":"item","_id":0}}
> {"id":"0","name":"Jowar Puffed"}
> {"index":{"_index":"fooditems","_type":"item","_id":1}}
> {"id":"1","name":"Uamp and tea"}
> {"index":{"_index":"fooditems","_type":"item","_id":2}}
> {"id":"2","name":"Banana Chips"}

我遇到了错误

  

&#34;批量请求必须以换行符[\ n]&#34;

终止      

illegal_argument_exception

我不确定它想说什么。 请帮帮我。

0 个答案:

没有答案