public void deleteAll ( String name , String type ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/%s" , host , port , name , type ) ) ; try { EsRequest query = new EsRequest ( ) ; query . put ( "query" , new MatchAllQuery ( ) . build ( ) ) ; StringEntity requestEntity = new StringEntity ( query . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; method . setHeader ( " X-HTTP-Method-Override" , "DELETE" ) ; CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; if ( status != HttpStatus . SC_OK ) { throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } } finally { method . releaseConnection ( ) ; } }
Deletes all documents .