gpt4 book ai didi

elasticsearch - 在 Elasticsearch 6.4.0 中创建索引时的 mapper_parsing_exception

转载 作者:行者123 更新时间:2023-12-02 23:08:28 27 4
gpt4 key购买 nike

我正在尝试使用以下 JSON 创建 Elasticsearch 索引,这导致异常。我使用的 Elasticsearch 的当前版本是 6.4.0。
异常表示根映射定义具有不受支持的参数。不知道是什么问题

{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"filter": [
"lowercase"
],
"char_filter": [
"html_strip"
],
"type": "custom",
"tokenizer": "whitespace"
}
}
}
},
"mappings" :{
"properties" :{
"title" :{
"type" : "text",
"analyzer" : "my_analyzer"
}
}
}
}
这导致以下异常:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [title : {analyzer=my_analyzer, type=text}]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [properties]: Root mapping definition has unsupported parameters: [title : {analyzer=my_analyzer, type=text}]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [title : {analyzer=my_analyzer, type=text}]"
}
},
"status": 400
}

最佳答案

这是因为您没有添加 _doc在您的 mappings部分,这是因为 types are deprecated并了解为什么必须在 schedule_for_removal_of_mapping_types 中提到的 Elasticsearch 6.X 版本中添加此内容
请引用Elasticsearch 6.4 official doc on how to create mappings.
要使其工作,您需要添加 _doc在映射部分如下:

{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"filter": [
"lowercase"
],
"char_filter": [
"html_strip"
],
"type": "custom",
"tokenizer": "whitespace"
}
}
}
},
"mappings": {
"_doc": { // Note this, you need to add this
"properties": {
"title": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}
}

关于elasticsearch - 在 Elasticsearch 6.4.0 中创建索引时的 mapper_parsing_exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62606647/

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