How to do an ElasticSearch Select Distinct

You’re almost there, you simply need to add a terms aggregation to your query

{
   "query" : {
        "bool" : {
               "should" : [ 
                  { "term" : { "userid" : "20" } }, 
                  { "term" : { "activity" : "9" } }
               ]
         }
    },
    "aggs":{
        "unique_ids": {
            "terms": {
                "field": "id"
            }
        }
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)