ElasticSearch 7.4.2 Root mapping definition has unsupported parameters


新建索引

PUT people

{
    "settings":{
        "number_of_shards":3,
        "number_of_replicas":1
    },
    "mappings":{
        "man":{
            "properties":{
                "name":{
                    "type":"text"
                },
                "country":{
                    "type":"keyword"
                },
                "age":{
                    "type":"integer"
                },
                "date":{
                    "type":"date",
                    "format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
                }
            }
        }    
    }
}

然后,報錯:Root mapping definition has unsupported parameters

查看官網示例后發現 7.4 默認不在支持指定索引類型,默認索引類型是_doc(隱含:include_type_name=false)。見官網:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_typeless_apis_in_7_0

修改:

{
    "settings": {
        "number_of_shards": 3,
        "number_of_replicas": 1
    },
    "mappings": {
        "properties": {
            "name": {
                "type": "text"
            },
            "country": {
                "type": "keyword"
            },
            "age": {
                "type": "integer"
            },
            "date": {
                "type": "date",
                "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
            }
        }
    }
}

 如果你要像之前舊版版本一樣兼容自定義 type ,需要將 include_type_name=true 攜帶, 見官網示例: https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_index_templates

PUT localhost:9200/people?include_type_name=true

但是這一字段將在8.x 舍棄

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM