Visualize line chart with top hit aggregation and sum

Hi, i have this kind of data...

finger is unique per hw(computer) and put doc for example every hour... There is also total_devices available in put time

I want to make line graph with daily date histogram on x-axe and sum of total devices on y-axes, but only newest value for unique finger

Thanks for help

I have been playing around with this and haven't been able to figure out a solution. I am going to reach out and see if this is possible with the TSVB visualization.

Here is the data I have been sampling for anyone else that wants to give it a look:

DELETE discuss-101523

PUT discuss-101523
{
  "settings": {},
  "mappings": {
    "doc": {
      "properties": {
        "total_devices": {
          "type": "integer"
        },
        "finger": {
          "type": "keyword"
        },
        "date": {
          "type": "date"
        }
      }
    }
  }
}


POST discuss-101523/doc
{
  "total_devices": 11,
  "finger": "x-y-z",
  "date": "2017-09-22T01:00:00"
}

POST discuss-101523/doc
{
  "total_devices": 6,
  "finger": "x-y-z",
  "date": "2017-09-22T02:00:00"
}

POST discuss-101523/doc
{
  "total_devices": 10,
  "finger": "q-w-e",
  "date": "2017-09-22T01:00:00"
}

POST discuss-101523/doc
{
  "total_devices": 5,
  "finger": "q-w-e",
  "date": "2017-09-22T02:00:00"
}


POST /discuss-101523/_search
{
  "aggs": {
    "group": {
      "terms": {
        "field": "finger"
      },
      "aggs": {
        "group_docs": {
          "top_hits": {
            "size": 1,
            "sort": [
              {
                "date": {
                  "order": "desc"
                }
              }
            ]
          }
        }
      }
    }
  }
}
1 Like

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