[elk]驗證mapping字段數和數據字段數關係

驗證一個mapping下字段缺乏或者超過

結論: 沒有什麼不能夠.
1.若是數據字段不在mapping裏,則動態會更新mapping.
2.數據字段數也能夠小於mapping裏字段數app

  • 建立一個mapping
DELETE /lib2

PUT /lib2
{
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1
  },
  "mappings": {
    "user": {
      "properties":{
        "name":{"type":"keyword"},
        "age":{"type":"integer"},
        "address":{"type":"text"},
        "birth":{"type":"date"}
      }
    }
  }
}


GET /lib2/_mapping
PUT /lib2/user/1
{
  "name":"maotai1",
  "age":21,
  "address":"shan xi xian",
  "birth":"2018-02-06T06:22:59.00Z"
}
  • 少兩個字段
PUT /lib2/user/2
{
  "name":"maotai2",
  "age":22
}
  • 多一個favor字段
PUT /lib2/user/3
{
  "name":"maotai3",
  "age":23,
  "address":"shan xi xian",
  "birth":"2018-02-06T06:22:59.00Z",
  "favor":["book","sleep"]
}
  • 查詢
GET /lib2/user/_search
{
  "query": {
    "match_all": {}
  }
}

如下幾種狀況都是ok的

mapping字段數 == 數據字段數
code

mapping字段數 >= 數據字段數
blog

mapping字段數 <= 數據字段數
date

相關文章
相關標籤/搜索