# Bug when aggregating histogram fields

**URL:** <https://discuss.elastic.co/t/bug-when-aggregating-histogram-fields/288013>\
**Category:** Elasticsearch\
**Created:** [October 29, 2021, 3:24pm UTC](https://discuss.elastic.co/t/bug-when-aggregating-histogram-fields/288013 "2021-10-29T15:24:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![romainneutron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/romainneutron/32/96533_2.png) [@romainneutron](https://discuss.elastic.co/u/romainneutron)\
**Post date:** [October 29, 2021, 3:24pm UTC](https://discuss.elastic.co/t/bug-when-aggregating-histogram-fields/288013/1 "2021-10-29T15:24:43Z")

</div>

Hello,

I encounter an issue with some particular values using histogram aggregations:

Here's a reproducer:

```auto
PUT test-index
{
  "mappings" : {
    "properties" : {
      "my_histogram" : {
        "type" : "histogram"
      }
    }
  }
}

PUT test-index/_doc/1
{
  "my_histogram": {
    "counts": [
      2100000000,
      300000000
    ],
    "values": [
      1000,
      2000
    ]
  }
}

GET test-index/_search
{
  "aggs": {
    "wt_96th_percentile": {
      "percentiles": {
        "field": "my_histogram",
        "percents": [
          "96.0"
        ]
      }
    }
  }
}

```

Here's the result I got:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_state_exception",
        "reason" : "Negative longs unsupported, use writeLong or writeZLong for negative numbers [-1894967296]"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "test-index",
        "node" : "EJmqZRg-RWy1WYbItsbmHQ",
        "reason" : {
          "type" : "illegal_state_exception",
          "reason" : "Negative longs unsupported, use writeLong or writeZLong for negative numbers [-1894967296]"
        }
      }
    ],
    "caused_by" : {
      "type" : "illegal_state_exception",
      "reason" : "Negative longs unsupported, use writeLong or writeZLong for negative numbers [-1894967296]",
      "caused_by" : {
        "type" : "illegal_state_exception",
        "reason" : "Negative longs unsupported, use writeLong or writeZLong for negative numbers [-1894967296]"
      }
    }
  },
  "status" : 500
}

```

Is it a bug? Should I report it on the GitHub repo?

Thanks,  
Romain

---

<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:** [November 26, 2021, 3:24pm UTC](https://discuss.elastic.co/t/bug-when-aggregating-histogram-fields/288013/2 "2021-11-26T15:24:53Z")

</div>

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