Create an index
- PUT /{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.
- Index privileges:
create_index,manage
Path Parameters
-
indexstring IndexNamerequired -
Name of the index you wish to create. Index names must meet the following criteria:
- Lowercase only
- Cannot include
\,/,*,?,",<,>,|,(space character),,, or# - Indices prior to 7.0 could contain a colon (
:), but that has been deprecated and will not be supported in later versions - Cannot start with
-,_, or+ - Cannot be
.or.. - Cannot be longer than 255 bytes (note thtat it is bytes, so multi-byte characters will reach the limit faster)
- Names starting with
.are deprecated, except for hidden indices and internal indices managed by plugins
Query Parameters
-
master_timeoutstring Duration · default: 30s 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.
-
timeoutstring Duration · default: 30s Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
-
wait_for_active_shardsWaitForActiveShards · default: 1 The number of shard copies that must be active before proceeding with the operation. Set to
allor any positive integer up to the total number of shards in the index (number_of_replicas+1).-
Values:
allindex-setting
Request
-
aliasesmap string to Alias -
Aliases for the index.
-
<string>Alias -
filterQueryContainer -
Query used to limit documents the alias can access.
-
index_routingstring -
Value used to route indexing operations to a specific shard. If specified, this overwrites the
routingvalue for indexing operations. -
If
true, the alias is hidden. All indices for the alias must have the sameis_hiddenvalue. -
is_write_indexboolean · default: false -
If
true, the index is the write index for the alias. -
routingstring -
Value used to route indexing and search operations to a specific shard.
-
search_routingstring -
Value used to route search operations to a specific shard. If specified, this overwrites the
routingvalue for search operations. -
mappingsTypeMapping -
Mapping for fields in the index. If specified, this mapping can include:
- Field names
- Field data types
- Mapping parameters
-
all_fieldAllField -
analyzerstringrequired -
enabledbooleanrequired -
omit_normsbooleanrequired -
search_analyzerstringrequired -
similaritystringrequired -
storebooleanrequired -
store_term_vector_offsetsbooleanrequired -
store_term_vector_payloadsbooleanrequired -
store_term_vector_positionsbooleanrequired -
store_term_vectorsbooleanrequired -
date_detectionboolean -
dynamicDynamicMapping -
Values:
strictruntimetruefalse -
dynamic_date_formatsstring -
dynamic_templatesstring to DynamicTemplate -
_field_namesFieldNamesField -
enabledbooleanrequired -
index_fieldIndexField -
enabledbooleanrequired -
_metaMetadata -
numeric_detectionboolean -
propertiesmap string to Property -
_sourceSourceField -
enabledboolean -
excludesstring -
includesstring -
modeSourceFieldMode -
Supported values include:
disabledstoredcolumnar_storedsynthetic: Instead of storing source documents on disk exactly as you send them, Elasticsearch can reconstruct source content on the fly upon retrieval.
-
Values:
disabledstoredcolumnar_storedsynthetic -
runtimemap string to RuntimeField -
<string>RuntimeField -
fieldsmap string to CompositeSubField -
For type
composite -
<string>CompositeSubField -
typeRuntimeFieldTyperequired -
Values:
booleancompositedatedoublegeo_pointgeo_shapeipkeywordlonglookup -
formatstring -
A custom format for
datetype runtime fields. -
input_fieldstring Field -
For type
lookup -
target_fieldstring Field -
For type
lookup -
target_indexstring IndexName -
For type
lookup -
scriptstring Script -
Painless script executed at query time.
-
on_script_errorOnScriptError -
Values:
failcontinue -
typeRuntimeFieldTyperequired -
Field type, which can be:
boolean,composite,date,double,geo_point,ip,keyword,long, orlookup. -
Values:
booleancompositedatedoublegeo_pointgeo_shapeipkeywordlonglookup -
enabledboolean -
subobjectsSubobjects -
Values:
truefalse -
_data_stream_timestampDataStreamTimestamp -
enabledbooleanrequired -
settingsIndexSettings -
Configuration options for the index.
Response
-
indexstring IndexNamerequired -
shards_acknowledgedbooleanrequired -
acknowledgedbooleanrequired