public <T> T get(String path, String entity, Class<T> clazz) throws ElasticsearchClientException { String uri = String.format("http://%s:%d%s", hostname, port, path); log.debug(String.format("Sending GET request to %s with entity '%s'", uri, entity)); HttpGetWithEntity request = new HttpGetWithEntity(uri); request.setHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.getMimeType()); request.setEntity(new StringEntity(entity, ContentType.APPLICATION_JSON)); String content = executeRequest(request); T result = deserialize(content, clazz); return result; }