Histogram range aggragation keys

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:


"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

{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?

Just to be sure. Is this Elasticsearch 8.0.0?

sorry, not that latest

  "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.

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

7.7.1-1

1 Like

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

It is working with 7.17 version.
Thank you!

1 Like

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