# Increase doc\_count even if record is same in date\_histogram on Array field

**URL:** <https://discuss.elastic.co/t/increase-doc-count-even-if-record-is-same-in-date-histogram-on-array-field/328257>\
**Category:** Elasticsearch\
**Created:** [March 22, 2023, 2:16pm UTC](https://discuss.elastic.co/t/increase-doc-count-even-if-record-is-same-in-date-histogram-on-array-field/328257 "2023-03-22T14:16:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbhimanyuSharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhimanyusharma/32/118763_2.png) [@AbhimanyuSharma](https://discuss.elastic.co/u/AbhimanyuSharma)\
**Post date:** [March 22, 2023, 2:16pm UTC](https://discuss.elastic.co/t/increase-doc-count-even-if-record-is-same-in-date-histogram-on-array-field/328257/1 "2023-03-22T14:16:41Z")

</div>

I have an object / array field which contains date-time. This field contains every second of the duration between start and end time of some event. I am doing this because I want to see the running events on each second. So my field me look like this,

```auto
{
  "_index" : "timeline",
  "_id" : "GGWGB4cBU8qsnVUf4m44",
  "fields" : {
    "upTimeArr" : [
      "1679458442000",
      "1679458443000",
      "1679458444000",
      "1679458445000",
      "1679458446000",
      "1679458447000",
      "1679458448000",
      "1679458449000",
      "1679458450000",
      "1679458451000",
      "1679458452000",
      "1679458453000",
      "1679458454000",
      "1679458455000"
    ]
  }
}

```

Now, if I will run a **date\_histogram** aggregation with **fixed\_interval** as **"01s"**

```auto
GET timeline/_search
{
  "aggs": {
    "0": {
     "date_histogram": {
            "field": "upTimeArr",
            "fixed_interval": "01s",
            "time_zone": "Asia/Calcutta",
            "min_doc_count": 1
          }
    }
  },
  
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              {
                "match_phrase": {
                  "_id": "GGWGB4cBU8qsnVUf4m44"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

then my result will be something like this,

```auto
"buckets" : [
        {
          "key" : 1679458442000,
          "doc_count" : 1
        },
        {
          "key" : 1679458443000,
          "doc_count" : 1
        },
        {
          "key" : 1679458444000,
          "doc_count" : 1
        },
        {
          "key" : 1679458445000,
          "doc_count" : 1
        },
        {
          "key" : 1679458446000,
          "doc_count" : 1
        },
        {
          "key" : 1679458447000,
          "doc_count" : 1
        },
        {
          "key" : 1679458448000,
          "doc_count" : 1
        },
        {
          "key" : 1679458449000,
          "doc_count" : 1
        },
        {
          "key" : 1679458450000,
          "doc_count" : 1
        },
        {
          "key" : 1679458451000,
          "doc_count" : 1
        },
        {
          "key" : 1679458452000,
          "doc_count" : 1
        },
        {
          "key" : 1679458453000,
          "doc_count" : 1
        },
        {
          "key" : 1679458454000,
          "doc_count" : 1
        },
        {
          "key" : 1679458455000,
          "doc_count" : 1
        }
      ]

```

( I have removed "key\_as\_string" from the result )

But if I will set fixed\_interval as 10 secs

```auto
"fixed_interval": "10s"

```

then the result will be,

```auto
"buckets" : [
  {
    "key" : 1679458440000,
    "doc_count" : 1
  },
  {
    "key" : 1679458450000,
    "doc_count" : 1
  },
  {
    "key" : 1679458460000,
    "doc_count" : 1
  }
]

```

In all the above cases "doc\_count" is 1 for each bucket which is correct because document is actually just one. But in my case, if I the fixed\_interval is 10s then there should be some count which can represent the contribution of each member of the **"upTimeArr"** field.

I am expecting the result something like this,

```auto
"buckets" : [
  {
    "key" : 1679458440000,
    "count" : 8
  },
  {
    "key" : 1679458450000,
    "count" : 6
  }
]

```

Is it possible to achieve this?

---

<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:** [April 19, 2023, 2:17pm UTC](https://discuss.elastic.co/t/increase-doc-count-even-if-record-is-same-in-date-histogram-on-array-field/328257/2 "2023-04-19T14:17:24Z")

</div>

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