美文网首页
005 IndexTemlate & DynamicTemple

005 IndexTemlate & DynamicTemple

作者: zhu733756 | 来源:发表于2020-03-16 16:47 被阅读0次

    #IndexTemlate & DynamicTemple

    #index模板可以用正则设定,order指的是优先级

    PUT  /_template/default_template

    {

      "settings":{

        "number_of_shards":1,

        "number_of_replicas":1

      },

      "index_patterns":["*"],

      "order":0,

      "version":1

    }

    PUT /_template/default_test

    {

      "settings": {

        "number_of_shards": 1,

        "number_of_replicas": 2

      },

      "index_patterns": [

        "test*"

      ],

      "order": 1,

      "version": 1,

      "mappings": {

        "date_detection": false,

        "numeric_detection": true

      }

    }

    GET _template/default_*

    #借助dynamicTemplate可以实现一定格式的字段进行类型推断

    DELETE my_index

    PUT my_index

    {

      "mappings": {

        "dynamic_templates": [

          {

            "is2boolean": {

              "match_mapping_type": "string",

              "match": "is*",

              "mapping": {

                "type": "boolean"

              }

            }

          },

          {

            "name_transfer": {

              "path_match": "name.*",

              "path_unmatch": "*.middle",

              "mapping": {

                "type": "text",

                " ": "fullName"

              }

            }

          }

        ]

      }

    }

    PUT my_index/_doc/1

    {

      "name":{

        "first":"John",

        "middle":"Winston",

        "last":"Lennon"

      },

      "isVip":"true"

    }

    GET my_index/_search?q=fullName:John

    GET my_index/_mapping

    相关文章

      网友评论

          本文标题:005 IndexTemlate & DynamicTemple

          本文链接:https://www.haomeiwen.com/subject/thrnehtx.html