| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 | [[indices-create-index]]== Create IndexThe create index API allows to instantiate an index. Elasticsearchprovides support for multiple indices, including executing operationsacross several indices.[float][[create-index-settings]]=== Index SettingsEach index created can have specific settingsassociated with it.[source,js]--------------------------------------------------$ curl -XPUT 'http://localhost:9200/twitter/'$ curl -XPUT 'http://localhost:9200/twitter/' -d 'index :    number_of_shards : 3 <1>    number_of_replicas : 2 <2>'--------------------------------------------------<1> Default for `number_of_shards` is 5<2> Default for `number_of_replicas` is 1 (ie one replica for each primary shard)The above second curl example shows how an index called `twitter` can becreated with specific settings for it using http://www.yaml.org[YAML].In this case, creating an index with 3 shards, each with 2 replicas. Theindex settings can also be defined with http://www.json.org[JSON]:[source,js]--------------------------------------------------$ curl -XPUT 'http://localhost:9200/twitter/' -d '{    "settings" : {        "index" : {            "number_of_shards" : 3,            "number_of_replicas" : 2        }    }}'--------------------------------------------------or more simplified[source,js]--------------------------------------------------$ curl -XPUT 'http://localhost:9200/twitter/' -d '{    "settings" : {        "number_of_shards" : 3,        "number_of_replicas" : 2    }}'--------------------------------------------------[NOTE]You do not have to explicitly specify `index` section inside the`settings` section.For more information regarding all the different index level settingsthat can be set when creating an index, please check the<<index-modules,index modules>> section.[float][[mappings]]=== MappingsThe create index API allows to provide a set of one or more mappings:[source,js]--------------------------------------------------curl -XPOST localhost:9200/test -d '{    "settings" : {        "number_of_shards" : 1    },    "mappings" : {        "type1" : {            "_source" : { "enabled" : false },            "properties" : {                "field1" : { "type" : "string", "index" : "not_analyzed" }            }        }    }}'--------------------------------------------------[float][[warmers]]=== WarmersThe create index API allows also to provide a set of <<indices-warmers,warmers>>:[source,js]--------------------------------------------------curl -XPUT localhost:9200/test -d '{    "warmers" : {        "warmer_1" : {            "source" : {                "query" : {                    ...                }            }        }    }}'--------------------------------------------------[float][[create-index-aliases]]=== AliasesThe create index API allows also to provide a set of <<indices-aliases,aliases>>:[source,js]--------------------------------------------------curl -XPUT localhost:9200/test -d '{    "aliases" : {        "alias_1" : {},        "alias_2" : {            "filter" : {                "term" : {"user" : "kimchy" }            },            "routing" : "kimchy"        }    }}'--------------------------------------------------[float]=== Creation DateWhen 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:[source,js]--------------------------------------------------curl -XPUT localhost:9200/test -d '{    "creation_date" : 1407751337000 <1>}'--------------------------------------------------<1> `creation_date` is set using epoch time in milliseconds.
 |