Mysql equivalent query for having clause

I am looking for elastic search query equivalent to mysql query as below:-

SELECT *, COUNT(ID) FROM EMP GROUP BY ID HAVING COUNT(ID) > 3 ORDER BY ID DESC;

Below Elastic search Query i am using:-

curl -XGET 'localhost:9200/emp/_search?pretty' -H 'Content-Type: application/json' -d'`enter code here`
{
  "aggs": {
    "group_by_id": {
      "terms": {                                                       
        "field": "id",
        "min_doc_count" : 3                              
      }
    }  
  }
}'

but its returning only id value and doc_count.If i mentioned size in it then its returning _source field with data but its return rows one by one.

I need all fields with last inserted record same as my sql query returing means only single row for particular id.

Please help.

PLEASE UPDATE ITS CRITICAL FOR ME.

Please be patient. This forum is staffed by volunteers, so give users time to respond. If there has been no response in a day or two, feel free to bump the question.

Thanks Christian_Dahlqvist i am new with elastic search and forum also.I will wait thanks for suggest.

Any genius please update..its already too late.

Please read About the Elasticsearch category

If you need support with service level agreement then you can buy support from elastic.

Otherwise be patient as written in the post I linked to.

Remember that lot of people don't work on Saturday and Sunday.

1 Like

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