Create Index API
editCreate Index API
editCreate Index Request
editA CreateIndexRequest
requires an index
argument:
Index settings
editEach index created can have specific settings associated with it.
Index mappings
editAn index may be created with mappings for its document types
Index aliases
editAliases can be set at index creation time
Optional arguments
editThe following arguments can optionally be provided:
Timeout to wait for the all the nodes to acknowledge the index creation as a |
|
Timeout to wait for the all the nodes to acknowledge the index creation as a |
Timeout to connect to the master node as a |
|
Timeout to connect to the master node as a |
Synchronous Execution
editCreateIndexResponse createIndexResponse = client.indices().create(request);
Asynchronous Execution
editThe asynchronous execution of a create index request requires both the CreateIndexRequest
instance and an ActionListener
instance to be passed to the asynchronous
method:
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 CreateIndexResponse
looks like:
Create Index Response
editThe returned CreateIndexResponse
allows to retrieve information about the executed
operation as follows: