I saw the post here where you guys gave solution for the link given below. ElasticSearch Java API to get distinct values from the Query Builders
Is there any way to achieve distinct emails using org.elasticsearch.client.RestHighLevelClient
?
Could you please help me on this, i tried so many ways but could not able to solve it. But I am able to achieve the same in SQL Workbench and the equivalent json query is given below using Kibana translator.
SELECT DISTINCT email_client.keyword
FROM email_reference;
Equivalent Elasticsearch query given below:
{
"from": 0,
"size": 0,
"_source": {
"includes": ["email_client.keyword"],
"excludes": []
},
"stored_fields": "email_client.keyword",
"aggregations": {
"email_client.keyword": {
"terms": {
"field": "email_client.keyword",
"size": 200,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
]
}
}
}
}
So now i wanted form this JSON query using RestHighLevelClient, I have tried but the problem is prepareSearch() is not there in RestHighLevelClient is there any other to achieve using RestHighLevelClient?