summaryrefslogtreecommitdiff
path: root/docs/reference/indices/create-index.asciidoc
blob: 0b069d3ce10002cb03128ec4b7fe5e405a738fff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
[[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]
--------------------------------------------------
$ curl -XPUT 'http://localhost:9200/twitter/'

$ curl -XPUT 'http://localhost:9200/twitter/' -d '
index :
    number_of_shards : 3
    number_of_replicas : 2
'
--------------------------------------------------

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]
--------------------------------------------------
$ 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 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 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]]
=== Warmers

The 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" : {
                    ...
                }
            }
        }
    }
}'
--------------------------------------------------