# DateRangeAggregation minDocCount filter

**URL:** <https://discuss.elastic.co/t/daterangeaggregation-mindoccount-filter/165888>\
**Category:** Elasticsearch\
**Created:** [January 27, 2019, 9:45am UTC](https://discuss.elastic.co/t/daterangeaggregation-mindoccount-filter/165888 "2019-01-27T09:45:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shira\_Bendor](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Shira\_Bendor](https://discuss.elastic.co/u/Shira_Bendor)\
**Post date:** [January 27, 2019, 9:45am UTC](https://discuss.elastic.co/t/daterangeaggregation-mindoccount-filter/165888/1 "2019-01-27T09:45:16Z")

</div>

Hi,  
I'm on version 6.5.3 using this aggregation via the java api and I don't see a way to filter based on numDocCount. Is there such a way and I just missed it? or if not, I would like to propose it.

Here is my code:

```
> AggregationBuilder myagg = new CompositeAggregationBuilder("stats1", Arrays.asList( "1","2","3","4)).size(10000);
> myagg
> .subAggregation(new ExtendedStatsBucketPipelineAggregationBuilder("stats2", "current>sum"))
> .subAggregation(new DateRangeAggregationBuilder("stats3")
> .field(DATETIME)
> .addRange(DateTime.now().minusWeeks(4), DateTime.now().minusWeeks(4).plusHours(3)) --> here I want to filter only if docCount > 1
> .addRange(DateTime.now().minusWeeks(3), DateTime.now().minusWeeks(3).plusHours(3))
> .addRange(DateTime.now().minusWeeks(2), DateTime.now().minusWeeks(2).plusHours(3))
> .addRange(DateTime.now().minusWeeks(1), DateTime.now().minusWeeks(1).plusHours(3))
> .subAggregation(new SumAggregationBuilder("stats4")
> .field("myField))))

```

Thanks  
Shira

---

<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:** [February 24, 2019, 9:45am UTC](https://discuss.elastic.co/t/daterangeaggregation-mindoccount-filter/165888/2 "2019-02-24T09:45:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
