<commit_before>[[indices-create-index]]
== Create Index

The create index API allows to instantiate an index. Elasticsearch
provides support for multiple indices, including executing operations
across several indices.

[float]
[[create-index-settings]]
=== Index Settings

Each index created can have specific settings
associated with it.

[source,js]
--------------------------------------------------
PUT twitter
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3, <1>
            "number_of_replicas" : 2 <2>
        }
    }
}
--------------------------------------------------
// CONSOLE
<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 be
created with specific settings for it using http://www.yaml.org[YAML].
In this case, creating an index with 3 shards, each with 2 replicas. The
index settings can also be defined with http://www.json.org[JSON]:

[source,js]
--------------------------------------------------
PUT twitter
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3,
            "number_of_replicas" : 2
        }
    }
}
--------------------------------------------------
// CONSOLE

or more simplified

[source,js]
--------------------------------------------------
PUT twitter
{
    "settings" : {
        "number_of_shards" : 3,
        "number_of_replicas" : 2
    }
}
--------------------------------------------------
// CONSOLE

[NOTE]
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,index modules>> section.


[float]
[[mappings]]
=== Mappings

The create index API allows to provide a type mapping:<commit_msg>[DOCS] Document index name limitations (#30826)<commit_after>[[indices-create-index]]
== Create Index

The Create Index API is used to manually create an index in Elasticsearch.  All documents in Elasticsearch
are stored inside of one index or another.

The most basic command is the following:

[source,js]
--------------------------------------------------
PUT twitter
--------------------------------------------------
// CONSOLE

This create an index named `twitter` with all default setting.

[NOTE]
.Index name limitations
======================================================
There are several limitations to what you can name your index.  The complete list of limitations are:

- Lowercase only
- Cannot include `\`, `/`, `*`, `?`, `"`, `<`, `>`, `|`, ` ` (space character), `,`, `#`
- Indices prior to 7.0 could contain a colon (`:`), but that's been deprecated and won't be supported in 7.0+
- Cannot start with `-`, `_`, `+`
- Cannot be `.` or ``..`
- Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster)

======================================================

[float]
[[create-index-settings]]
=== Index Settings

Each index created can have specific settings
associated with it, defined in the body:

[source,js]
--------------------------------------------------
PUT twitter
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3, <1>
            "number_of_replicas" : 2 <2>
        }
    }
}
--------------------------------------------------
// CONSOLE
<1> Default for `number_of_shards` is 5
<2> Default for `number_of_replicas` is 1 (ie one replica for each primary shard)

or more simplified

[source,js]
--------------------------------------------------
PUT twitter
{
    "settings" : {
        "number_of_shards" : 3,
        "number_of_replicas" : 2
    }
}
--------------------------------------------------
// CONSOLE

[NOTE]
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,index modules>> section.


[float]
[[mappings]]
=== Mappings

The create index API allows to provide a type mapping:
{'fraction_non_alphanumeric': 0.2553039332538737, 'fraction_numerical': 0.009296781883194279, 'mean_word_length': 2.0014306151645207, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4813755', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1076, 'n_words': 425}