GitHub user sebbASF opened an issue:
https://github.com/apache/incubator-ponymail/issues/276
Enh: stats.lua could use single aggregate query to get first and last years
stats.lua currently sorts all the records by date in ascending and
descending order, picking the first result. It then has to extract the date
from _source.
The same information could be retrieved using an aggregation of the form:
```
{
"size": 0,
"query" : {etc},
"aggs": {
"first": {
"min": {
"field": "date"
}
},
"last": {
"max": {
"field": "date"
}
}
}
}
```
This returns info in the form:
```
"aggregations": {
"last": {
"value": 1479983095000,
"value_as_string": "2016/11/24 10:24:55"
},
"first": {
"value": 1479115199000,
"value_as_string": "2016/11/14 09:19:59"
}
}
```
----
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---