Group_concat aggragation

Hello everybody. I am new to elasticsearch and I would like to create a group_concat aggregation. But I don't know how. Can someone help me please.

The example data:

    POST /example_measures/_bulk
    {"index":{"_id":1}}
    {"id":"1","datapoint_id":"1","datetime":"1577833200000","value":"5"}
    {"index":{"_id":2}}
    {"id":"2","datapoint_id":"2","datetime":"1577833210000","value":"51"}
    {"index":{"_id":3}}
    {"id":"3","datapoint_id":"2","datetime":"1577833220000","value":"77"}

What i want expressed in sql:

    select datapoint_id, 
    group_concat(`datetime` order by `datetime` SEPARATOR ',' limit 5) as dt, 
    group_concat(`value` order by `datetime` SEPARATOR ',' limit 5) as val 
    from example_measures 
    group by datapoint_id;

I would like to have 2 arrays per data point. One with the timestamps and one with the values.

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