I'm trying to use elasticsearch to give me 30-day statistics for a given
collection of models (pertinent fields are a date in *created_at* and an
integer in *value*). Currently, I have this query/aggregation:
{
"query": {
"match_all": {}
},
"aggregations": {
"date_histogram": {
"field": "created_at",
"interval": "30d",
"min_doc_count": 0,
"extended_bounds": {
"min": 1381881600000, // Dynamically generated for 365 days ago
(This is 2013-10-16 00:00:00 +0000)
"max": 1413503999000 // Dynamically generated for end of today
(This is 2014-10-16 23:59:59 +0000)
}
},
"aggregations": {
"stats": {
"extended_stats": {
"field": "value"
}
}
}
}
}
It's working as expected, except for one thing: the buckets don't line up
as expected. For some reason, *the last bucket always starts on 2014-10-07
00:00:00 +0000, regardless of what data is in elasticsearch*. I have tried
this aggregation on a bunch of different date ranges, including:
- 1 model instance per day for the past 30 days
- 1 model instance per day for the past 365 days
- 1 model instance total, for a *created_at* of 2014-09-30
- 1 model instance total, for a *created_at* of 2014-10-15
- 1 model instance total, for a *created_at* of 2014-10-16
- 1 model instance total, for a *created_at* of 2014-10-31
I have also tried to adjust the *extended bounds*, which doesn't shift the
bucket dates at all.
The result is that the last bucket is always giving a date of 2014-10-07.
This throws off the statistics because the last bucket isn't a full 30 days
of material, whereas the rest of buckets are.
*My questions:*
*- Why are the buckets always pivoting around October 7th? *My expectation
is that it pivots around 30 days prior to *extend_bounds["max"]*.
*- Is there a way to tune this?*
Thank you in advance for any help you can give.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/87fe5659-50c5-4870-8139-12a680b94c9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.