新建索引
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 舍弃