推荐索引模板

最近更新时间:2020-03-06 11:14:52

推荐索引模板保存在文件template.json中,内容如下:

{
    "order": 0,
    "template": "*",
    "settings": {
        "index": {
            "max_result_window": "65536",
            "routing": {
                "allocation": {
                    "require": {
                        "box_type": "hot"
                    }
                }
            },
            "search": {
                "slowlog": {
                    "threshold": {
                        "query": {
                            "warn": "10s",
                            "info": "5s"
                        }
                    }
                }
            },
            "refresh_interval": "60s",
            "unassigned": {
                "node_left": {
                    "delayed_timeout": "5m"
                }
            },
            "indexing": {
                "slowlog": {
                    "threshold": {
                        "index": {
                            "warn": "10s",
                            "info": "5s"
                        }
                    }
                }
            },
            "number_of_shards": "5",
            "translog": {
                "flush_threshold_size": "5g",
                "sync_interval": "60s",
                "durability": "async"
            },
            "number_of_replicas": "1"
        }
    },
    "mappings": {
        "_default_": {
            "dynamic_templates": [{
                    "all_tpl": {
                        "mapping": {
                            "ignore_above": 1024,
                            "index": "not_analyzed",
                            "type": "{dynamic_type}",
                            "doc_values": true
                        },
                        "match": "*"
                    }
                },
                {
                    "strings": {
                        "match_mapping_type": "string",
                        "mapping": {
                            "type": "keyword"
                        }
                    }
                }
            ],
            "_all": {
                "enabled": false
            }
        }
    },
    "aliases": {}
}

模板生效命令: curl -H "Content-Type: application/json" -XPUT "es_ip:es_port/_template/.default" -d @template.json

金山云,开启您的云计算之旅

免费注册