I having a template mappings like this:
{
"template": "ones_bug-*",
"settings": {
"index": {
"number_of_shards": "5",
"number_of_replicas": "1"
}
},
"mappings": {
"bug_info": {
"_all": {
"enabled": false
},
"properties": {
"createdAt": {
"type": "date"
},
"startAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
},
"closeAt": {
"type": "date"
},
"expectClose": {
"type": "date"
},
"crashMsg": {
"type": "text"
},
"expectTime": {
"type": "float"
},
"actualWorkTime": {
"type": "float"
},
"fixDuration": {
"type": "float"
},
"closeDuration": {
"type": "float"
},
"bugReason": {
"type": "keyword"
},
"onesId": {
"type": "keyword"
},
"state": {
"type": "keyword"
},
"iterationId": {
"type": "keyword"
},
"moduleId": {
"type": "keyword"
},
"severityId": {
"type": "keyword"
},
"severityName": {
"type": "keyword"
},
"createdUser": {
"type": "keyword"
},
"updatedUser": {
"type": "keyword"
},
"verifiedUser": {
"type": "keyword"
},
"assignedUser": {
"type": "keyword"
},
"subtypeId": {
"type": "keyword"
},
"priority": {
"type": "keyword"
},
"priorityId": {
"type": "keyword"
},
"priorityName": {
"type": "keyword"
},
"labels": {
"type": "keyword"
},
"title": {
"type": "keyword"
},
"projectId": {
"type": "keyword"
},
"md5": {
"type": "keyword"
},
"onesUrl": {
"type": "text"
}
}
}
},
"aliases": {}
}
Now, I want to query some docs by DSL which like the sql:
select count(state) from (
select max(updateAt), onesId from master group by onesId
) group by state
How could I write this DSL?