Elasticsearch学习笔记——Mapping创建及dynamic_templates

Mapping

mapping可以理解为Elasticsearch的表结构,作用是为了定义index的schema。包含有定义字段的数据类型,存储形式等等。

创建Mapping

mapping创建

Elasticsearch在创建索引的时候可以显式定义mapping,也可以不指定mapping,通过写入数据的形式让Elasticsearch自己推断mapping。

显示指定mapping创建index

# 显示指定mapping创建index
PUT label
{
   
  "mappings": {
   
    "label":{
   
    "properties":{
   
      "cust_id":{
   "type":"keyword"},
      "ast9_bal":{
   "type":"double"},
      "vip_flag":{
   "type":"keyword"},
      "blng_org_id" : {
   "type":"keyword"},
      "open_dt":{
   "type":"date"}
    }
    }
  }
}

# 查看mapping定义
GET label1/_mapping
{
   
  "label1": {
   
    "mappings": {
   
      "label1": {
   
        "properties": {
   
          "ast9_bal": {
   
            "type": "double"
          },
          "cust_id": {
   
            "type": "keyword"
          }
        }
      }
    

你可能感兴趣的:(Elasticsearch,elasticsearch,大数据,es)