gpt4 book ai didi

elasticsearch - invalid_argument_exception未找到搜索字段的映射

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

我正在使用5.1版本学习ElasticSearch。我有一个索引“mycontent”和一个类型“simpledocument”。我在尝试检查simpledocument类型的建议/完成功能时遇到错误“illegal_argument_exception,未找到字段映射”。详细信息如下:

GET _search
{
"suggest":{
"my-suggestion":{
"prefix":"ap",
"completion":{
"field":"suggest"
}
}
}
}

这给了我响应:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 5,
"failed": 1,
"failures": [
{
"shard": 0,
"index": ".kibana",
"reason": {
"type": "illegal_argument_exception",
"reason": "no mapping found for field [suggest]"
}
}
]
},
......

映射中确实包含“建议”字段:
GET _mapping/simpledocument

{
"mycontent": {
"mappings": {
"simpledocument": {
"properties": {
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "integer"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"path": {
"type": "keyword"
},
"suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
},
"tags": {
"type": "keyword"
}
}
}
}
}
}

这是一个示例文档:
GET mycontent/simpledocument/7
{
"_index": "mycontent",
"_type": "simpledocument",
"_id": "7",
"_version": 1,
"found": true,
"_source": {
"name": "Suggested Document",
"description": "this document does not contain a lot of content. Mainly used to test the suggest feature.",
"tags": [
"suggest",
"document"
],
"suggest": [
"and",
"design",
"api"
]
}
}

有人可以帮我弄清楚我的错误吗?为什么存在映射时为什么显示“未找到映射”?

最佳答案

GET _search将搜索所有索引,这是错误的意思,它表示索引.kibana没有suggest字段,因为您的GET _mapping/simpledocument建议字段仅应存在于simpedocument 索引类型中。

所以也许您需要这样做:

GET mycontent/simpledocument/_search
{
"suggest":{
"my-suggestion":{
"prefix":"ap",
"completion":{
"field":"suggest"
}
}
}
}

关于elasticsearch - invalid_argument_exception未找到搜索字段的映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43728211/

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