Scripted fields from the result of aggregations and the nested aggregations

I have a aggregation as

GET /ats/_search
{
"size": 0,
"aggs": {
"accessTimes": {
"date_histogram": {
"field": "accessTime",
"interval": "hour"
},
"aggs": {
"hit_docs": {
"filter": {
"terms": {
"cacheResult": ["tcp_mem_hit","tcp_hit","tcp_refresh_hit"]
}
....

And the response is

{
....
"aggregations": {
"accessTimes": {
"buckets": [
{
"key_as_string": "2015-02-19T11:00:00.000Z",
"key": 1424343600000,
"doc_count": 14,
"hit_docs": {
"doc_count": 13
}
},
{
"key_as_string": "2015-02-19T12:00:00.000Z",
"key": 1424347200000,
"doc_count": 52,
"hit_docs": {
"doc_count": 41
}
},
{
"key_as_string": "2015-02-19T13:00:00.000Z",
"key": 1424350800000,
"doc_count": 231,
"hit_docs": {
"doc_count": 136
}
},
{
"key_as_string": "2015-02-19T14:00:00.000Z",
"key": 1424354400000,
"doc_count": 13161,
"hit_docs": {
"doc_count": 8957
}
},
{
"key_as_string": "2015-02-19T15:00:00.000Z",
"key": 1424358000000,
"doc_count": 8971,
"hit_docs": {
"doc_count": 5631
}
...

I want to know whether there is some way to access the field of
aggregations.buckets.doc_count and a*ggregations.buckets.hit_docs.doc_count
*and calculate the hit ration from these two values. Finally, I want to
view it from kiban4.

Thanks,
Cong

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/78241d3c-a51f-4b72-8708-5b2dc7583cbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.