Elasticsearch version : 7.1
Postman version : 7.8.0我的url如下所示
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索引中。
我已经被这个问题困扰了好几个小时了。我试过不同的方法,但都不管用。我想做的是使用postman插入到elastic search中。我已经定义了我的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"
}
}
}
}
}我将下面的身体传递给邮递员。
{
"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
}将body更改为以下内容后的Update 2:
{
"_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
}发布于 2019-10-18 17:26:24
您发送的json正文格式不正确。括号没有按正确的顺序闭合,并且缺少正文的键名称。以下是正确的json格式
{
"_index": "catalog",
"_type": "_doc"
"input": "roast beef",
"output": {
"category": "Sides",
"item": "Large Roast-Beef Sandwich",
"modifiers": [
"LG"
],
"quantity": 1
}
}发布于 2019-10-18 20:14:49
向http://localhost:9200/menu/发出一个PUT调用(假设您在默认端口上的本地运行elastic,索引名称为'menu')。
在正文中包括你的maaping,如下所示:
{
"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"
}
}
}
}
}
}这将创建索引,结果如下(响应):
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "menu"
}https://stackoverflow.com/questions/58447460
复制相似问题