There is no such thing as a perfect program, but that doesn’t discourage us, because writing a program is a constant pursuit of perfection.

Q: What are the features of dynamic_templates?

A:



Q: How to use dynamic_templates?

A:

# set /dynamic_templates_test # set/templates_test"mappings" : {
    "dynamic_templates": [{"integers" : {
          "match_mapping_type" : "long"."match"              : "*_age"."unmatch"            : "name_*"."mapping"            : {
            "type" : "integer"}}}, {"strings" : {
          "match_mapping_type" : "string"."path_match"         : "*.name"."path_unmatch"       : "user.age"."mapping"            : {
            "type"   : "text"."fields" : {
              "raw" : {
                "type"         : "keyword"."ignore_above" : 256}}}}}, {"d_dynamic" : {
          "match_mapping_type" : "string"."path_match"         : "analyzer_name.*"."mapping"            : {
            "type"     : "{dynamic_type}"."analyzer" : "{name}"."store"    : true}}} # index POST /dynamic_templates_test/_doc/1
{
  "my_number" : 324324234."my_age"    : 324324234."my_string" : "hello"."user"      : {
    "name" : "good"."age"  : 18
  },
  "analyzer_name" : {
    "standard" : "hello"."english"  : "good"}} # show mapping GET /dynamic_templates_test"dynamic_templates_test" : {
    "mappings" : {
      "dynamic_templates": [{"integers" : {
            "match" : "*_age"."unmatch" : "name_*"."match_mapping_type" : "long"."mapping" : {
              "type" : "integer"}}}, {"strings" : {
            "path_match" : "*.name"."path_unmatch" : "user.age"."match_mapping_type" : "string"."mapping" : {
              "fields" : {
                "raw" : {
                  "ignore_above" : 256."type" : "keyword"}},"type" : "text"}}}, {"d_dynamic" : {
            "path_match" : "analyzer_name.*"."match_mapping_type" : "string"."mapping" : {
              "analyzer" : "{name}"."store" : true."type" : "{dynamic_type}"}}}]."properties" : {
        "analyzer_name" : {
          "properties" : {
            "english" : {
              "type" : "text"."store" : true."analyzer" : "english"
            },
            "standard" : {
              "type" : "text"."store" : true."analyzer" : "standard"}}},"my_age" : {
          "type" : "integer"
        },
        "my_number" : {
          "type" : "long"
        },
        "my_string" : {
          "type" : "text"."fields" : {
            "keyword" : {
              "type" : "keyword"."ignore_above" : 256}}},"user" : {
          "properties" : {
            "age" : {
              "type" : "long"
            },
            "name" : {
              "type" : "text"."fields" : {
                "raw" : {
                  "type" : "keyword"."ignore_above" : 256
                }
              }
            }
          }
        }
      }
    }
  }
}
Copy the code