如何聚集在其上具有一格式11/03/2015
即治療字符串作爲日期,而無需重新索引類型的字符串字段?例如,考慮的映射關係對一個Elasticsearch index:sport
,type:athlete
:如何聚集在字符串類型的elasticsearch字段,其包括一斜槓(/)
curl -XPUT "http://localhost:9200/sports/" -d'
{
"mappings": {
"athlete": {
"properties": {
"birthdate": {
"type": "string"
},
"name": {
"type": "string"
},
"score": {
"type": "integer"
},
"sport": {
"type": "string"
}
}
}
}
}
集結上birthdate
出現使用/
分離字段,因此聚集體上11/03/2015
作爲11
,03
,2015
而不是採取作爲一個整體和聚集在它。如何解決這個問題? :
"buckets": [
{
"key": "2015",
"doc_count": 24
},
{
"key": "11",
"doc_count": 21
},
{
"key": "03",
"doc_count": 3
}
]