How to use Max Aggregation value in Filter Aggregation

I need to use the Max aggregation value, See below query.

              "aggregations":{

                    "maxValue": {
                       "max": {
                         "field": "value"
                       }
                    },
                    "result" : {
                      "filter": {
                        "script": {
                          "script": {
                            "inline": "valueParam> 50 && valueParam< 100",
                            "params": {
                              "valueParam" : "maxValue"
                            }
                          }
                        }
                      }
                    }

                }

I am not able to execute query like above.
Please suggest how can I use Max aggregation value in other aggregations?
Thanks

Have a look at https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html

Thanks for your quick response,, I am trying but still no success. :frowning: Can you please provide me any example by using the max aggregation value in filter aggregation script, as I mentioned in question ?

I have tried like above but getting exception:

    "reason": {
                   "type": "script_exception",
                   "reason": "failed to run inline script [valueParam> 50 && valueParam< 100] using lang [groovy]",
                   "caused_by": {
                      "type": "class_cast_exception",
                      "reason": "java.lang.Integer cannot be cast to java.lang.String"
                   }
                }

Are you using an old version of elasticsearch?

I am using "2.3.2"

Try with "valueParam" : maxValue instead of "valueParam" : "maxValue"

When I use -> "valueParam" : maxValue

"reason": {
               "type": "json_parse_exception",
               "reason": "Unrecognized token 'maxValue': was expecting ('true', 'false' or 'null')\n at [Source: [B@bff38e; line: 111, column: 53]"
            }

When I use-> "valueParam" : "maxValue"

"reason": {
               "type": "script_exception",
               "reason": "failed to run inline script [valueParam > 50 && valueParam< 100] using lang [groovy]",
               "caused_by": {
                  "type": "class_cast_exception",
                  "reason": null
               }
            }

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