{"index_patterns":["haihui_items_index*"],"template":{"settings":{"index":{"lifecycle":{"name":"haihui_items_index_policy"},"number_of_shards":"3","number_of_replicas":"2"}},"mappings":{"_routing":{"required":false},"numeric_detection":false,"dynamic_date_formats":["strict_date_optional_time","yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"],"_source":{"excludes":[],"includes":[],"enabled":true},"dynamic":true,"dynamic_templates":[],"date_detection":true,"properties":{"score":{"type":"double"},"item_id":{"type":"keyword"}}}},"composed_of":[],"priority":100,"version":1,"_meta":{"description":"haihui items index template by x-pack","managed":true},"data_stream":{"hidden":false}}
创建管理的index的lifetime
PUT _ilm/policy/my_policy
{"policy":{"_meta":{"description":"used for nginx log","project":{"name":"myProject","department":"myDepartment"}},"phases":{"warm":{"min_age":"10d","actions":{"forcemerge":{"max_num_segments":1}}},"delete":{"min_age":"30d","actions":{"delete":{}}}}}}
ES定义index
PUT /myIndex
{"index_templates":[{"name":"haihui_items_index_template","index_template":{"index_patterns":["haihui_items_index*"],"template":{"settings":{"index":{"lifecycle":{"name":"haihui_items_index_policy"},"number_of_shards":"3","number_of_replicas":"2"}},"mappings":{"_routing":{"required":false},"numeric_detection":false,"dynamic_date_formats":["strict_date_optional_time","yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"],"_source":{"excludes":[],"includes":[],"enabled":true},"dynamic":true,"dynamic_templates":[],"date_detection":true,"properties":{"score":{"type":"double"},"item_id":{"type":"keyword"}}}},"composed_of":[],"priority":100,"version":1,"_meta":{"description":"haihui items index template by x-pack","managed":true},"data_stream":{"hidden":false}}}]}