es 基础概念总结 —— 动态映射

1.映射 mapping

作用:

  • 定义字段名称与数据类型
  • 定义倒排索引(是否被索引,采用的 analyzer

示例

PUT data/_doc/1 
{ "count": 5, "date": "2015/09/02" }

GET data/_mapping

创建了 data 索引,映射类型为 _doc, 字段 count 的数据类型为 long

{
  "data" : {
    "mappings" : {
      "properties" : {
        "count" : {
          "type" : "long"
        },
        "date" : {
          "type" : "date",
          "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
        }
      }
    }
  }
}

2.动态字段映射

日期检测(默认启用)

 禁用

PUT my_index
{
  "mappings": {
    "date_detection": false
  }
}

 自定义映射格式

PUT my_index
{
  "mappings": {
    "dynamic_date_formats": ["MM/dd/yyyy"]
  }
}

数字检测(默认禁用)

PUT my_index
{
  "mappings": {
    "numeric_detection": true
  }
}

PUT my_index/_doc/1
{
  "my_float":   "1.0", 
  "my_integer": "1" 
}

233

参考资料


https://www.elastic.co/guide/en/elasticsearch/reference/7.6/dynamic-mapping.html

猜你喜欢

转载自www.cnblogs.com/lemos/p/12508723.html