ElasticSearch 7.x 报错:Root mapping definition has unsupported parameters

原因:

ElasticSearch 7.x 默认不在支持指定索引类型

在postman中用以下数据执行put请求:

{"mappings": {
        "person" :{
            "properties": {
                "age": {
                    "type": "integer"
                },
                "hobby": {
                    "type": "text"
                },
                "mail": {
                    "type": "text"
                },
                "name": {
                    "type": "keyword"
                }
            }
        }
            
        }
}

报错:

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [person : {properties={mail={type=text}, name={type=keyword}, age={type=integer}, hobby={type=text}}}]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [person : {properties={mail={type=text}, name={type=keyword}, age={type=integer}, hobby={type=text}}}]",
        "caused_by": {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [person : {properties={mail={type=text}, name={type=keyword}, age={type=integer}, hobby={type=text}}}]"
        }
    },
    "status": 400
}

但是对于ElasticSearch 6.x执行时没有问题的,elasticsearch7默认不在支持指定索引类型,默认索引类型是_doc,如果想改变,则配置include_type_name: true 即可(这个没有测试,官方文档说的,无论是否可行,建议不要这么做,因为elasticsearch8后就不在提供该字段)。官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

所以在ElasticSearch 7.x中不指定索引类型,创建索引是成功的,请看结果:

ElasticSearch 7.x 报错:Root mapping definition has unsupported parameters_第1张图片

你可能感兴趣的:(ElasticSearch 7.x 报错:Root mapping definition has unsupported parameters)