WARNING: Version 2.1 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Create Index
editCreate Index
editThe create index API allows to instantiate an index. Elasticsearch provides support for multiple indices, including executing operations across several indices.
Index Settings
editEach index created can have specific settings associated with it.
$ curl -XPUT 'http://localhost:9200/twitter/' $ curl -XPUT 'http://localhost:9200/twitter/' -d ' index : number_of_shards : 3 number_of_replicas : 2 '
Default for |
|
Default for |
The above second curl example shows how an index called twitter
can be
created with specific settings for it using YAML.
In this case, creating an index with 3 shards, each with 2 replicas. The
index settings can also be defined with JSON:
$ curl -XPUT 'http://localhost:9200/twitter/' -d '{ "settings" : { "index" : { "number_of_shards" : 3, "number_of_replicas" : 2 } } }'
or more simplified
$ curl -XPUT 'http://localhost:9200/twitter/' -d '{ "settings" : { "number_of_shards" : 3, "number_of_replicas" : 2 } }'
You do not have to explicitly specify index
section inside the
settings
section.
For more information regarding all the different index level settings that can be set when creating an index, please check the index modules section.
Mappings
editThe create index API allows to provide a set of one or more mappings:
curl -XPOST localhost:9200/test -d '{ "settings" : { "number_of_shards" : 1 }, "mappings" : { "type1" : { "_source" : { "enabled" : false }, "properties" : { "field1" : { "type" : "string", "index" : "not_analyzed" } } } } }'
Warmers
editThe create index API allows also to provide a set of warmers:
curl -XPUT localhost:9200/test -d '{ "warmers" : { "warmer_1" : { "source" : { "query" : { ... } } } } }'
Aliases
editThe create index API allows also to provide a set of aliases:
curl -XPUT localhost:9200/test -d '{ "aliases" : { "alias_1" : {}, "alias_2" : { "filter" : { "term" : {"user" : "kimchy" } }, "routing" : "kimchy" } } }'
Creation Date
editWhen an index is created, a timestamp is stored in the index metadata for the creation date. By
default this it is automatically generated but it can also be specified using the
creation_date
parameter on the create index API: