Create an index
/{index} You can use the create index API to add a new index to an Elasticsearch cluster. When creating an index, you can specify the following:
- Settings for the index.
- Mappings for fields in the index.
- Index aliases
Wait for active shards
By default, index creation will only return a response to the client when the primary copies of each shard have been started, or the request times out.
The index creation response will indicate what happened.
For example, acknowledged indicates whether the index was successfully created in the cluster, while shards_acknowledged indicates whether the requisite number of shard copies were started for each shard in the index before timing out.
Note that it is still possible for either acknowledged or shards_acknowledged to be false, but for the index creation to be successful.
These values simply indicate whether the operation completed before the timeout.
If acknowledged is false, the request timed out before the cluster state was updated with the newly created index, but it probably will be created sometime soon.
If shards_acknowledged is false, then the request timed out before the requisite number of shards were started (by default just the primaries), even if the cluster state was successfully updated to reflect the newly created index (that is to say, acknowledged is true).
You can change the default of only waiting for the primary shards to start through the index setting index.write.wait_for_active_shards.
Note that changing this setting will also affect the wait_for_active_shards value on all subsequent write operations.
Required authorization
- Index privileges:
create_index,manage
Parameters
path Path Parameters
| Name | Type |
|---|---|
index
required
Name of the index you wish to create. Index names must meet the following criteria:
| type TypesIndexName = string |
query Query Parameters
| Name | Type |
|---|---|
master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. | type TypesDuration = string | "-1" | "0" |
timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. | type TypesDuration = string | "-1" | "0" |
wait_for_active_shards The number of shard copies that must be active before proceeding with the operation.
Set to | type TypesWaitForActiveShards = type TypesWaitForActiveShardOptions = "all" | "index-setting" | number |