zoukankan      html  css  js  c++  java
  • es index template

    建一个索引的步骤

    1:先创建轮滚策略

    2:创建模板

    3:创建索引

    创建轮滚策略

    PUT _ilm/policy/this_is_an_index_policy
    {
        
        "policy" : {
          "phases" : {
            "hot" : {
              "min_age" : "0ms",
              "actions" : {
                "rollover" : {
                  "max_size" : "100gb",
                  "max_age" : "7d"
                }
              }
            },
            "delete" : {
              "min_age" : "7300d",
              "actions" : {
                "delete" : { }
              }
            }
          }
        }
    } 

    创建索引模板

    PUT /_template/this-is-an-index-template
    {
        "order" : 0,
        "index_patterns" : [
          "this-is-an-index-*"
        ],
        "settings" : {
          "index" : {
            "lifecycle" : {
              "name" : "this_is_an_index_policy",  # 这里要指向刚才创建的轮滚策略
              "rollover_alias" : "this-is-an-index"  # 这个是轮滚后的索引的别名
            },
            "search" : {
              "slowlog" : {
                "level" : "info",
                "threshold" : {
                  "fetch" : {
                    "warn" : "800ms",
                    "info" : "300ms"
                  },
                  "query" : {
                    "warn" : "800ms",
                    "info" : "300ms"
                  }
                }
              }
            },
            "refresh_interval" : "60s",
            "number_of_shards" : "6",
            "number_of_replicas" : "1"
          }
        },
        "mappings" : {
          "dynamic" : "false",
          "properties" : {
            "os_info" : {
              "type" : "keyword"
            },
            "app" : {
              "type" : "keyword"
            },
            "content" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "ignore_above" : 256,
                  "type" : "keyword"
                }
              }
            },
            "province" : {
              "type" : "keyword"
            }
          }
        },
        "aliases" : {}
      }

    根据模板创建索引

    PUT /this-is-an-index-000001

    {
      "aliases": {
        "this-is-an-index": {
          "is_write_index" : true
          }
       }
    }

    创建索引后,如果要观察轮滚效果,可以手动滚动

    POST /this-is-an-index/_rollover

    ref: https://www.cnblogs.com/sanduzxcvbnm/p/12085103.html

  • 相关阅读:
    PAT 1035. 插入与归并(25)
    PAT 1034. 有理数四则运算(20)
    PAT 1033. 旧键盘打字(20)
    PAT 1032. 挖掘机技术哪家强(20)
    PAT 1031. 查验身份证(15)
    PAT 1030. 完美数列(25)
    PAT 1029. 旧键盘(20)
    PAT 1028. 人口普查(20)
    PAT 1027. 打印沙漏(20)
    PAT 1026. 程序运行时间(15)
  • 原文地址:https://www.cnblogs.com/buxizhizhoum/p/15705543.html
Copyright © 2011-2022 走看看