# Date range aggregation vs filters aggregation with range filter

**URL:** https://discuss.elastic.co/t/date-range-aggregation-vs-filters-aggregation-with-range-filter/21987
**Category:** Elasticsearch
**Created:** [February 5, 2015, 11:02am UTC](https://discuss.elastic.co/t/date-range-aggregation-vs-filters-aggregation-with-range-filter/21987 "2015-02-05T11:02:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Maxim\_Valyanskiy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maxim_valyanskiy/32/787_2.png) [@Maxim\_Valyanskiy](https://discuss.elastic.co/u/Maxim_Valyanskiy)
#### Post date: [February 5, 2015, 11:02am UTC](https://discuss.elastic.co/t/date-range-aggregation-vs-filters-aggregation-with-range-filter/21987/1 "2015-02-05T11:02:16Z")

</div>

Hello!

I use date range aggregation to calculate counts for several fixed periods  
(like 'today', 'this week', 'this month' & etc). This variants are shown  
via radio-buttons in web interface. Also I need to add "total" variant that  
counts total number of documents .

My current solution uses total document count value from some upper level  
source (like upper level filter aggregation or bucket of terms  
aggregation). This causes a lot of complications in my source code.

I have an idea to simplify it by replacing date range aggregation with  
filters aggregation that holds range filters for my periods and matchall  
filter to count total value. I wonder is there any performance problems  
with this solution? What is faster to execute, date rage aggregation or  
filters aggregation with range filters?

Is there any other solutions for this problem?

Maxim

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7ebe5b84-ca86-468c-bcf0-7fe128417274%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7ebe5b84-ca86-468c-bcf0-7fe128417274%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 12:34am UTC](https://discuss.elastic.co/t/date-range-aggregation-vs-filters-aggregation-with-range-filter/21987/2 "2017-07-06T00:34:50Z")

</div>


