【发布时间】:2020-02-16 11:31:25
【问题描述】:
我正在尝试在我的elasticsearch 实例中插入一个JSON 数据文件。
curl -s -H “Content-Type: application/x-ndjson” -XPOST localhost:9200/_bulk —-data-binary “@restaurants.json”; echo
但是,执行此命令后,我收到一条错误消息,提示
{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}
JSON 文件基本上具有以下对象的数组。 唯一的问题是我在这里只放了一个对象以节省空间。但是,存在不止一个对象。
结构如下所示;
[
{
"address": {
"building": "351",
"coord": [
-73.98513559999999,
40.7676919
],
"street": "West 57 Street",
"zipcode": "10019"
},
"borough": "Manhattan",
"cuisine": "Irish",
"name": "Dj Reynolds Pub And Restaurant",
"grades": [
{
"date": {
"$date": "2014-09-06T00:00:00.000Z"
},
"grade": "A",
"score": 2
},
{
"date": {
"$date": "2013-07-22T00:00:00.000Z"
},
"grade": "A",
"score": 11
},
{
"date": {
"$date": "2012-07-31T00:00:00.000Z"
},
"grade": "A",
"score": 12
},
{
"date": {
"$date": "2011-12-29T00:00:00.000Z"
},
"grade": "A",
"score": 12
}
],
"id": "30191841"
}
]
【问题讨论】:
-
这个答案可能会有所帮助:stackoverflow.com/questions/33340153/…
标签: elasticsearch