# Where to add min\_doc-count

**URL:** <https://discuss.elastic.co/t/where-to-add-min-doc-count/248612>\
**Category:** Elasticsearch\
**Created:** [September 15, 2020, 7:03am UTC](https://discuss.elastic.co/t/where-to-add-min-doc-count/248612 "2020-09-15T07:03:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![imantha](https://avatars.discourse-cdn.com/v4/letter/i/6a8cbe/32.png) [@imantha](https://discuss.elastic.co/u/imantha)\
**Post date:** [September 15, 2020, 7:03am UTC](https://discuss.elastic.co/t/where-to-add-min-doc-count/248612/1 "2020-09-15T07:03:20Z")

</div>

```
 let peopleCount = {
  size: 0,
  aggs: {
     'min_doc_count': 0,
    group_by_day: {
     // min_doc_count: 0,
      date_histogram: {
        field: 'timestamp',
        interval: '1d',
        time_zone: '+11:00',
        //format : 'yyyy-MM-dd'
      },
      aggs: {
      // min_doc_count: 0,
        Location: {
          filter: {
           
            match: {
              'data.name': 'Entrance',
            
            },
          
          },
          aggs: {
            // min_doc_count: '0',
            cou: {
              sum: {
                field: 'data.north',
              },
             
            },
            
          },
        },
      },
    },
   
  },
  query: {
    bool: {
      
      must: [
        {
          // range: { timestamp: { gte: startDate, lte: endDate } }
          range: { timestamp: { gte: '2020-03-20', lte: '2020-03-28' } },
        },
        {
          term: {
            account: accountId,
          },
        },
        {
          term: {
            'device._id': deviceId,
          },
        },
      ],
    },
  },
};`

```

this is my query for elastic search but i want to return all data if the result is zero. i try to add min-doc-count but i gives me this error  
`parsing_exception] Aggregation definition for [min_doc_count starts with a [VALUE_NUMBER], expected a [START_OBJECT]., with { line=1 & col=35 }`  
can you guys tell where should i add min doc count

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 17, 2020, 12:45pm UTC](https://discuss.elastic.co/t/where-to-add-min-doc-count/248612/2 "2020-09-17T12:45:40Z")

</div>

It needs to be added within the aggregation like

```auto
"my_agg_name" : {
  "terms" : {
    "field" : "foo",
    "min_doc_count" : 1234
  }
}

```

not all aggregations support this parameter though.

---

<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:** [October 15, 2020, 12:45pm UTC](https://discuss.elastic.co/t/where-to-add-min-doc-count/248612/3 "2020-10-15T12:45:48Z")

</div>

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