public void delete(String path) throws ElasticsearchClientException { String uri = String.format("http://%s:%d%s", hostname, port, path); log.debug(String.format("Sending DELETE request to %s", uri)); HttpDelete request = new HttpDelete(uri); executeRequest(request); }
public void put(String path, String entity) throws ElasticsearchClientException { String uri = String.format("http://%s:%d%s", hostname, port, path); log.info(String.format("Sending PUT request to %s with entity '%s'", uri, entity)); HttpPut request = new HttpPut(uri); request.setEntity(new StringEntity(entity, ContentType.APPLICATION_JSON)); executeRequest(request); }
public <T> T post(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 POST request to %s with entity '%s'", uri, entity)); HttpPost request = new HttpPost(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; }
public <T> T get(String path, 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", uri)); HttpGet request = new HttpGet(uri); request.setHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.getMimeType()); String content = executeRequest(request); T result = deserialize(content, clazz); return result; }
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; }