gpt4 book ai didi

elasticsearch - 无法解析_doc类型:Elasticsearch 7.x中的映射错误

转载 作者:行者123 更新时间:2023-12-02 23:45:04 29 4
gpt4 key购买 nike

尝试通过使用以下查询在Elasticsearch中创建索引

PUT company
{
"mappings": {
"employees": {
"properties": {
"id": {
"type": "long"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"birth": {
"type": "date"
},
"addr": {
"type": "text"
}
}
}
},
"settings": {
"index": {
"number_of_shards": "5",
"number_of_replicas": "1"
}
}
}

在Kibana仪表板中执行查询后出现以下错误
我认为有关天气的问题我给了一些错误的参数:
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [employees : {properties={name={type=text, fields={keyword={ignore_above=256, type=keyword}}}, birth={type=date}, id={type=long}, addr={type=text}}}]"
}
],
"type" : "mapper_parsing_exception",
"reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [employees : {properties={name={type=text, fields={keyword={ignore_above=256, type=keyword}}}, birth={type=date}, id={type=long}, addr={type=text}}}]",
"caused_by" : {
"type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [employees : {properties={name={type=text, fields={keyword={ignore_above=256, type=keyword}}}, birth={type=date}, id={type=long}, addr={type=text}}}]"
}
},
"status" : 400
}

最佳答案

根据此文件:

https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

从Elasticsearch 7.x版开始不赞成使用映射类型。您可以放置​​映射而无需另外提及_doc

PUT company
{
"mappings": {
"properties": {
"id": {
"type": "long"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"birth": {
"type": "date"
},
"addr": {
"type": "text"
}
}
},
"settings": {
"index": {
"number_of_shards": "5",
"number_of_replicas": "1"
}
}
}

输出:
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "company"
}

校验:
GET company/_mapping

输出:
{
"company" : {
"mappings" : {
"properties" : {
"addr" : {
"type" : "text"
},
"birth" : {
"type" : "date"
},
"id" : {
"type" : "long"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}

我希望这会有所帮助,更容易理解,并且避免 _doc属性引起混淆。

关于elasticsearch - 无法解析_doc类型:Elasticsearch 7.x中的映射错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61762521/

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