Help - Display correct document from multiple aggregation

I need help please.

I want to display a label in vega with information returned by one aggregation operation.

I'm only looking for just 2 documents the minimum and the maximum for the
log.json.sequence field.

When I access the values by data('minsequence')[0].aggregations.min_sequence.value and data('maxsequence')[0].aggregations.max_sequence.value It shows the correct values.

But when I access others values from respective documents like data('minsequence')[0].hits.hits[0]._source.time and data('maxsequence')[0].hits.hits[0]._source.time shows the wrong values and both of them looks like the same document.

Thanks

 "$schema": "https://vega.github.io/schema/vega/v5.json",
    "data": [
        {
          "name":"minsequence",
          "url": {
              "%context%": true,
              "%timefield%": "@timestamp",
              "index": "app.*",
              "body": {
                  "size": 1,
                  "aggs": 
                    {
                      "min_sequence": {
                          "min": {
                              "field": "log.json.sequence"
                          }
                      }                      
                    },
                    fields: ["*"]
              }
          }
        },
        {
          "name":"maxsequence",
          "url": {
              "%context%": true,
              "%timefield%": "@timestamp",
              "index": "app.*",
              "body": {
                  "size": 1,
                  "aggs": 
                    {
                      "max_sequence": {
                          "max": {
                              "field": "log.json.sequence"
                          }
                      }                      
                    },
                    fields: ["*"]
              }
          }
        }
    ],
    "marks": [
        {
            "type": "text",
            "encode": {
                "update": 
                {
                  "x": {"value": 0},
                  "y": {"value": 0},
                  "fontSize": {"value": 12},
                  "text": {
                      "signal":  "'First log - Min Sequence Value - ' + data('minsequence')[0].aggregations.min_sequence.value + ', tempo - ' + data('minsequence')[0].hits.hits[0]._source.time"
                  }
                }
            }
        },
        {
            "type": "text",
            "encode": {
                "update": 
                {
                  "x": {"value": 0},
                  "y": {"value": 15},
                  "fontSize": {"value": 12},
                  "text": {
                      "signal":  "'Last log - Min Sequence Value - ' + data('maxsequence')[0].aggregations.max_sequence.value + ', tempo - ' + data('maxsequence')[0].hits.hits[0]._source.time"
                  }
                }
            }
        }
    ] 
} 

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