Where to add min_doc-count

 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

It needs to be added within the aggregation like

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

not all aggregations support this parameter though.

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