es - mapping - dynamic mapping

·  阅读 223

世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。

问 :dynamic mapping内容有哪些?都有什么作用?
答 :
在这里插入图片描述
问 :dynamic field mapping是如何自定映射的?
答 :
在这里插入图片描述
问 :dynamic field mapping如何使用?
答 :

# dynamic field mapping
POST /dynamic_field_mapping_test/_doc/1
{
  "name"    : "hello good",
  "float"   : 9.04,
  "null"    : null,
  "boolean" : true,
  "integer" : 10,
  "date"    : "1989-01-10",
  "double"  : "0.87",
  "long"    : "78",
  "array"   : [null, "89"],
  "object"  : {
    "user" : {
      "name" : "hello",
      "age"  : 10
    }
  }
}

# mapping, 可以看到与文档中描述的额不同,
# String中的数字依然是字符串类型
GET /dynamic_field_mapping_test/_mapping

# 结果
{
  "dynamic_field_mapping_test" : {
    "mappings" : {
      "properties" : {
        "array" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "boolean" : {
          "type" : "boolean"
        },
        "date" : {
          "type" : "date"
        },
        "double" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "float" : {
          "type" : "float"
        },
        "integer" : {
          "type" : "long"
        },
        "long" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "object" : {
          "properties" : {
            "user" : {
              "properties" : {
                "age" : {
                  "type" : "long"
                },
                "name" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
复制代码
分类:
后端
标签:
收藏成功!
已添加到「」, 点击更改