如果我设置以下架构
curl -XPUT $myhost/some_index?pretty -d '
{
"mappings": {
"_mapping_name": {
"dynamic": false,
"properties": {
"field1": { "type": "long", "store": true },
"field2": { "type": "long", "store": true }
}
},
},
"settings" : {
"index" : {
"number_of_shards" : 9,
"number_of_replicas" : 1
}
}
}'
以下
curl -H "Content-Type: application/json" -XPOST "$myhost:9200/some_index/brand_new_mapping_name/" -d "{ \"field1\" : \"2\", \"field2\" : \"1\"}"
将创建新的类型brand_new_mapping_name
是否可以将弹性搜索配置为不创建类似于新dynamic = false
的新类型,以防止创建新字段?
答案 0 :(得分:2)
在版本5中,有一个选项可以在索引设置中禁用新的映射创建:https://www.elastic.co/guide/en/elasticsearch/reference/5.5/dynamic-mapping.html#_disabling_automatic_type_creation
但是在最新版本中,我再也无法在文档中找到它。可能是因为在即将发布的Elasticsearch版本中,每个索引的多个映射功能将被删除:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/removal-of-types.html
然后,您将不再能够创建第二个映射(通过designh,并且不再需要配置选项(index.mapper.dynamic":false
)。