gpt4 book ai didi

json - "unknown key [_index] for create index"

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

Elasticsearch version : 7.1
Postman version : 7.8.0

我的网址看起来像这样
http://localhost:9200/menu

我遇到的错误:
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unknown key [index] for create index"
}
],
"type": "parse_exception",
"reason": "unknown key [index] for create index"
},
"status": 400
}
Expected Result:成功将新文档输入 menu指数。

我已经被这个问题困扰了几个小时。我尝试了不同的东西,但没有一个有效。我想要做的插入 elastic search使用 postman .我已经定义了我的 mappings如下所示。
  "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"
}
}
}
}
}

我将以下 body 传递给 postman 。
{
"index": {
"_index": "catalog", "_type":"_doc"
}}
{"input": "roast beef", "output": {
"category": "Sides", "item": "Large Roast-Beef Sandwich", "modifiers": ["LG"], "quantity": 1
}
}
Update 1 : 把 body 改成下面这个。
{
"index": {
"_index": "catalog",
"_type": "_doc"
},
"key":{
"input": "roast beef",
"output": {
"category": "Sides",
"item": "Large Roast-Beef Sandwich",
"modifiers": [
"LG"
],
"quantity": 1
}
}
}

我现在收到错误
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unknown key [index] for create index"
}
],
"type": "parse_exception",
"reason": "unknown key [index] for create index"
},
"status": 400
}
Update 2:把 body 改成这个后
{       
"_index": "catalog",
"_type": "_doc",
"input": "roast beef",
"output": {
"category": "Sides",
"item": "Large Roast-Beef Sandwich",
"modifiers": [
"LG"
],
"quantity": 1
}
}

我收到以下错误
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unknown key [output] for create index"
}
],
"type": "parse_exception",
"reason": "unknown key [output] for create index"
},
"status": 400
}

最佳答案

您发送的 json 正文格式不正确。括号没有按正确的顺序关闭,并且 body 缺少键名。下面是正确的json格式

{       
"_index": "catalog",
"_type": "_doc"
"input": "roast beef",
"output": {
"category": "Sides",
"item": "Large Roast-Beef Sandwich",
"modifiers": [
"LG"
],
"quantity": 1
}
}

关于json - "unknown key [_index] for create index",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58447460/

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