# Histogram range aggragation keys

**URL:** <https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453>\
**Category:** Elasticsearch\
**Created:** [February 17, 2022, 8:36am UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453 "2022-02-17T08:36:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)\
**Post date:** [February 17, 2022, 8:36am UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/1 "2022-02-17T08:36:42Z")

</div>

Hi, after update to latest ES version, my range aggregation query started to work weird way.

I need histogram with predefine range values. My query looks like:

```auto

"aggs" : {

                    "agg" : {

                        "range" : {

                            "field" : field,

                            "ranges" : [

                                { "to" : 2.58 },

                                { "from" : 2.58, "to" : 3.1 },

                                { "from" : 3.1, "to": 3.6 },

                                { "from" : 3.6, "to": 4.03 },

                                { "from" : 4.03 }

                            ]

                        }

                    }

               }

```

I would expect answer to be like in previoues version that key IN NOT CHANGED. For example

`{key: "*-2.58"}, {key: "2.58-3.1"}, ...`

But it is

```auto
{key: "*-2.5799999237060547", doc_count: 0...}
{key: "2.5799999237060547-3.0999999046325684", doc_count: 2...}
{key: "3.0999999046325684-3.5999999046325684", doc_count:3…}
{key: "3.5999999046325684-4.03000020980835", doc_count: 3}
{key: "4.03000020980835-*", , doc_count: 3...}

```

How can I make key values fixed?

---

<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:** [February 17, 2022, 8:56am UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/2 "2022-02-17T08:56:50Z")

</div>

Just to be sure. Is this Elasticsearch 8.0.0?

---

<div class="post-metadata">

**Author:** ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)\
**Post date:** [February 17, 2022, 9:17am UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/3 "2022-02-17T09:17:27Z")

</div>

sorry, not that latest

```auto
  "version" : {
    "number" : "7.16.3",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "4e6e4eab2297e949ec994e688dad46290d018022",
    "build_date" : "2022-01-06T23:43:02.825887787Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },

```

That attribute where I search is set to float.

---

<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:** [February 17, 2022, 9:30am UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/4 "2022-02-17T09:30:08Z")

</div>

Ok, and one last ask: Which version did you use before where this worked as expected?

---

<div class="post-metadata">

**Author:** ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)\
**Post date:** [February 17, 2022, 9:47am UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/5 "2022-02-17T09:47:06Z")

</div>

7.7.1-1

---

<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:** [February 17, 2022, 11:18am UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/6 "2022-02-17T11:18:36Z")

</div>

Can you test with the latest 7.17 release? See [Fix bucket keys format for range aggregations on float field by salvatore-campagna · Pull Request #81801 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/pull/81801)

---

<div class="post-metadata">

**Author:** ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)\
**Post date:** [February 21, 2022, 9:01pm UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/7 "2022-02-21T21:01:48Z")

</div>

It is working with 7.17 version.  
Thank you!

---

<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:** [March 21, 2022, 9:02pm UTC](https://discuss.elastic.co/t/histogram-range-aggragation-keys/297453/8 "2022-03-21T21:02:24Z")

</div>

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