gpt4 book ai didi

批量插入的 json 结构无效

转载 作者:行者123 更新时间:2023-12-03 01:25:21 24 4
gpt4 key购买 nike

Elasticsearch version : 7.1
Postman version : 7.8.0
Elastic Search Url : http://localhost:9200/menu/_bulk
mapping
 "mappings": {
"properties": {
"input": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"output": {
"properties": {
"category": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"item": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"items": {
"properties": {
"category": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"item": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"modifiers": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"modifiers": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"quantity": {
"type": "long"
}
}
}
}
}

我收到的错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"
}
],
"type": "illegal_argument_exception",
"reason": "Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"
},
"status": 400
Expected Result : 成功将新文档添加到索引 menu Procedure
我正在尝试使用 elastic search 进行批量插入.我已经引用了文档,这是他们在下面提供的示例。
{ "index" : { "_index" : "testindex", "_type" : "somerandomtype", "_id" : "1" } }
{ "somefield" : "value1" }
{ "index" : { "_index" : "testindex", "_type" : "somerandomtype", "_id" : "2" } }
{ "somefield" : "hello hello hello" }

我以相同的方式建立了我的格式,但我不断收到错误。这就是我的 body看起来那是进入 postman .
{"index": { "_index": "menu", "_type":"_doc" } }
{"input": "angus-burger", "output": {
"category": "Sides", "item": "Angus-Deluxe Burger", "modifiers": [], "quantity": 1} }

我在这里做错了什么?

最佳答案

您的 Json 格式确实不正确。 postman 正文部分​​将显示给定 Json 的错误。
此外,批量请求正文并不意味着在单个有效 Json 中。

将相同的数据与 curl 一起使用,结果将是成功的。

此外,当使用 POSTMAN 的命令数据时,每个“部分”应该在一行内(即每一行代表一个有效的 json)。此外,不应有空行。
(这里与“bcp”命令有一些相似之处)

所以,这会工作

 {"index": { "_index": "menu", "_type":"_doc" } }
{"input": "angus-burger", "output": {"category": "Sides", "item": "Angus-Deluxe Burger", "modifiers": [], "quantity": 2} }

但这不适用于 postman 进行批量插入
{
"index": {
"_index": "menu",
"_type": "_doc"
}
}
{
"input": "angus-burger",
"output": {
"category": "Sides",
"item": "Angus-Deluxe Burger",
"modifiers": [],
"quantity": 2
}
}

关于批量插入的 json 结构无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58448995/

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