gpt4 book ai didi

elasticsearch - parse_exception - 请求正文是必需的

转载 作者:行者123 更新时间:2023-11-29 02:51:12 30 4
gpt4 key购买 nike

我正在尝试在我的 elasticsearch 实例中插入一个 JSON 数据文件。

curl -s -H “Content-Type: application/x-ndjson” -XPOST localhost:9200/_bulk —-data-binary “@restaurants.json”;回声

但是,在执行此命令后,我收到一条错误消息:

{"error":{"root_cause":[{"type":"parse_exception","re​​ason":"request body is required"}],"type":"parse_exception","re​​ason":"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"
}
]

最佳答案

批量 API 要求每行一个文档,这意味着您的文档中不能有换行符。尝试从您提交的 JSON 中去除所有空格。您也只是提交文档流,而不是对象的 JSON 数组。请在此处查看批量 API 文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

关于elasticsearch - parse_exception - 请求正文是必需的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48124737/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com