0

我正在尝试使用导致异常的以下 JSON 创建 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
}
4

1 回答 1

1

这是因为您没有_doc在您的mappings部分中添加,这是因为types are deprecated并了解为什么必须在 Elasticsearch 6.X 版本中添加,如schedule_for_removal_of_mapping_types中所述

有关如何创建映射,请参阅Elasticsearch 6.4 官方文档。

要使其工作,您需要_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"
                }
            }
        }
    }
}
于 2020-06-27T06:23:19.457 回答