Reputation: 21
This is my Elasticsearch-sql query. I executed this query using Kibana and getting valid output.
GET _sql?format=json { "query": "SELECT Count(appId) FROM eps_stbl_logs where cast(timestamp AS DATE) = TODAY() and status = 'COMPLETED'" }
This needs to be written in restHighLevelClient java API. Could you please help to write java API as I am new to ElasticSearch with Java.
Upvotes: 2
Views: 3065
Reputation: 41
It could work like this:
Request request = new Request("GET", "/_sql");
request.setJsonEntity("{\"query\":\"SELECT Count(appId) FROM eps_stbl_logs where cast(timestamp AS DATE) = TODAY() and status = 'COMPLETED'\"}");
Response response = restHighLevelClient.getLowLevelClient().performRequest(request);
String responseBody = EntityUtils.toString(response.getEntity());
Upvotes: 3