How can i get a distinct USERID from a table

I have a SQL query for SELECT DISTINCT(USER_ID) FROM TABLENAME

Need help to frame the query on Kibana for elastic search

Hello,

I'm not certain Elasticsearch SQL supports the distinct syntax, but you should be able to accomplish this using a terms aggregation. Something like the following:

GET /<your index>/_search
{
  "size": 0,
  "aggs": {
    "distinct_userids": {
      "terms": {
        "field": "userid",
        "size": 1000
      }
    }
  }
}

Regards,
Aaron

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