2017-10-26 03:52:46 -04:00
|
|
|
[[java-rest-high-delete-index]]
|
|
|
|
=== Delete Index API
|
|
|
|
|
|
|
|
[[java-rest-high-delete-index-request]]
|
|
|
|
==== Delete Index Request
|
|
|
|
|
|
|
|
A `DeleteIndexRequest` requires an `index` argument:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request]
|
|
|
|
--------------------------------------------------
|
|
|
|
<1> Index
|
|
|
|
|
|
|
|
==== Optional arguments
|
|
|
|
The following arguments can optionally be provided:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request-timeout]
|
|
|
|
--------------------------------------------------
|
|
|
|
<1> Timeout to wait for the all the nodes to acknowledge the index deletion as a `TimeValue`
|
|
|
|
<2> Timeout to wait for the all the nodes to acknowledge the index deletion as a `String`
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request-masterTimeout]
|
|
|
|
--------------------------------------------------
|
|
|
|
<1> Timeout to connect to the master node as a `TimeValue`
|
|
|
|
<2> Timeout to connect to the master node as a `String`
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request-indicesOptions]
|
|
|
|
--------------------------------------------------
|
|
|
|
<1> Setting `IndicesOptions` controls how unavailable indices are resolved and
|
|
|
|
how wildcard expressions are expanded
|
|
|
|
|
|
|
|
[[java-rest-high-delete-index-sync]]
|
|
|
|
==== Synchronous Execution
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-execute]
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[[java-rest-high-delete-index-async]]
|
|
|
|
==== Asynchronous Execution
|
|
|
|
|
2018-02-01 11:56:13 -05:00
|
|
|
The asynchronous execution of a delete index request requires both the `DeleteIndexRequest`
|
|
|
|
instance and an `ActionListener` instance to be passed to the asynchronous
|
|
|
|
method:
|
|
|
|
|
2017-10-26 03:52:46 -04:00
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-execute-async]
|
|
|
|
--------------------------------------------------
|
2018-02-01 11:56:13 -05:00
|
|
|
<1> The `DeleteIndexRequest` to execute and the `ActionListener` to use when
|
|
|
|
the execution completes
|
|
|
|
|
|
|
|
The asynchronous method does not block and returns immediately. Once it is
|
|
|
|
completed the `ActionListener` is called back using the `onResponse` method
|
|
|
|
if the execution successfully completed or using the `onFailure` method if
|
|
|
|
it failed.
|
|
|
|
|
|
|
|
A typical listener for `DeleteIndexResponse` looks like:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-execute-listener]
|
|
|
|
--------------------------------------------------
|
2017-10-26 03:52:46 -04:00
|
|
|
<1> Called when the execution is successfully completed. The response is
|
|
|
|
provided as an argument
|
|
|
|
<2> Called in case of failure. The raised exception is provided as an argument
|
|
|
|
|
|
|
|
[[java-rest-high-delete-index-response]]
|
|
|
|
==== Delete Index Response
|
|
|
|
|
|
|
|
The returned `DeleteIndexResponse` allows to retrieve information about the executed
|
|
|
|
operation as follows:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-response]
|
|
|
|
--------------------------------------------------
|
2017-12-07 05:39:59 -05:00
|
|
|
<1> Indicates whether all of the nodes have acknowledged the request
|
2017-10-26 03:52:46 -04:00
|
|
|
|
|
|
|
If the index was not found, an `ElasticsearchException` will be thrown:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
|
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-notfound]
|
|
|
|
--------------------------------------------------
|
|
|
|
<1> Do something if the index to be deleted was not found
|