Hello !
I have documents with a field that can store multiple dates like this:
{
"documentId": 481012,
"creationDate": "2016-06-02T17:30:34.232Z",
"activationDates": [
"2016-06-02T17:30:34.232Z",
"2016-06-03T17:30:34.232Z",
"2016-06-04T17:30:34.232Z",
"2016-06-05T17:30:34.232Z",
"2016-06-06T17:30:34.232Z",
...
]
}
Now I want to make a date_histogram aggregation on them, here is the query I'm using:
{
"aggs": {
"day_aggregation": {
"date_histogram": {
"field": "activationDates",
"interval" : "day"
}
}
}
}
The result is a list of buckets with a bucket for each date (as a day) present in all documents matching the query (all of them in this example because there is no filtering).
In my use case, I'd like to be able to have only 2016-06-03, 2016-06-04 and 2016-06-05 buckets in my final result. I can do this afterward in the application code but it would be better do do this in the query, if possible of course.
Is it possible to remove unwanted buckets ?
Here is a link of what I'd like to do: Filter out buckets in an aggregated query
But in his case he is working with terms aggregation and can simply use include/exclude. In my case I think it would be better to be able to filter out the unwanted buckets with range queries.
Any highlight would be appreciated, thank you !