Plot results of a script aggregation

(Parosio) #1

Hello, I'm trying to plot the results of a custom scripted aggregation, such as the following (based on flight data from

The aggregation returns the number of flights with the same weather in Origin and Destination:

GET flights/_search
  "size": 0,
  "_source": {
    "excludes": []
  "aggs": {
    "whatever": {
      "composite": {
        "sources": [
            "2": {
              "terms": {
                "script": {
                  "source": "if (doc['DestWeather.keyword'] == doc['OriginWeather.keyword']) return doc['DestWeather.keyword']; ",
                  "lang": "painless"
  "query": {
    "match_all": {}

and has been suggested in this elastic thread.

Another way to put it: only show the diagonal of this Heatmap:

I tried to use the above script in the 'JSON input' field of DestWeather aggregation, but only raised a variety of errors.

Am I correct this is the correct kibana thread to follow, or the question already has a solution?

(Jen Huang) #2

Try adding this script as a scripted field in Management > Index Patterns > Add scripted field. Then, you will be able to use the new field in the heat map visualization.

(Parosio) #3

Thank you, could not actually test it on flight example, but it should work.

(system) #4

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