数组

1. 数组中的 full-text 字段将被 【analyzed】

2. 数组中【所有元素】的数据类型必须一致

3. 数组的数据类型,以其 【第一个元素为准

 

映射

1. 数据类型会自动进行转化,比如 123 可以被转为 string ,但是 “test string” 没法转换为 long 类型

2. 使用 logstash 自动导入数据,filed 类型不一致将导致导入失败

3. 动态模板设置中,要把更精细的控制写在后面,否则精细的控制可能不会生效

{
    "order": 0,
    "template": "woc_test",
    "settings": {
        "index.number_of_shards": "3"
    },
    "mappings": {
        "old_report_date": {
            "dynamic_templates": [
                {
                    "not_analyzed": {
                        "mapping": {
                            "index": "not_analyzed",
                            "type": "string"
                        },
                        "match_mapping_type": "string"     //该模板匹配范围最广,必须第一个写,如果放在了最后,那么后面几个精确控制的模板都不会生效
                    }
                },
                {
                    "远程应用服务": {
                        "mapping": {
                            "index": "not_analyzed",
                            "type": "string"
                        },
                        "match": "远程应用服务"
                    }
                },
                {
                    "启用线路繁忙保护": {
                        "mapping": {
                            "index": "not_analyzed",
                            "type": "string"
                        },
                        "match": "启用线路繁忙保护"
                    }
                },
                {
                    "排除IP地址": {
                        "mapping": {
                            "index": "not_analyzed",
                            "type": "string"
                        },
                        "match": "排除IP地址"
                    }
                },
                {
                    "其它": {
                        "mapping": {
                            "index": "analyzed",
                            "type": "string"
                        },
                        "path_match": "其它.*"
                    }
                }
            ]
        }
    },
    "aliases": {}
}

相关文章: