Reputation: 37
I want to limit the results to a date range while performing the date histogram. But it seems to affect the results set (hits). Is there any way that I can do the same, but not affect the hits area?
Upvotes: 1
Views: 1178
Reputation: 19253
Filter aggregation would be an ideal match here.
{
"query": {
"match": {
"Content": "my query"
}
},
"aggs": {
"filterByDate": {
"filter": {
"range": {
"<dateField>": {
"gte": "<StartDate>",
"lt": "<EndDate>"
}
}
},
"aggs": {
"dateStats": {
"date_histogram": {
"field": "<dateField>"
}
}
}
}
}
}
Upvotes: 2