Skip to content

Commit fbecbcf

Browse files
authored
[DOCS] Reformat create index API docs (#45749)
1 parent 42690d0 commit fbecbcf

File tree

2 files changed

+83
-27
lines changed

2 files changed

+83
-27
lines changed

docs/reference/indices/create-index.asciidoc

Lines changed: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,98 @@
11
[[indices-create-index]]
2-
=== Create Index
2+
=== Create index API
3+
++++
4+
<titleabbrev>Create index</titleabbrev>
5+
++++
36

4-
The Create Index API is used to manually create an index in Elasticsearch. All documents in Elasticsearch
5-
are stored inside of one index or another.
6-
7-
The most basic command is the following:
7+
Creates a new index.
88

99
[source,js]
1010
--------------------------------------------------
11-
PUT twitter
11+
PUT /twitter
1212
--------------------------------------------------
1313
// CONSOLE
1414

15-
This creates an index named `twitter` with all default setting.
1615

17-
[NOTE]
18-
.Index name limitations
19-
======================================================
20-
There are several limitations to what you can name your index. The complete list of limitations are:
16+
[[indices-create-api-request]]
17+
==== {api-request-title}
18+
19+
`PUT /<index>`
20+
21+
[[indices-create-api-desc]]
22+
==== {api-description-title}
23+
You can use the create index API to add a new index to an {es} cluster. When
24+
creating an index, you can specify the following:
25+
26+
* Settings for the index
27+
* Mappings for fields in the index
28+
* Index aliases
29+
30+
31+
[[indices-create-api-path-params]]
32+
==== {api-path-parms-title}
33+
34+
`<index>`::
35+
+
36+
--
37+
(Optional, string) Name of the index you wish to create.
38+
39+
Index names must meet the following criteria:
2140

2241
- Lowercase only
2342
- Cannot include `\`, `/`, `*`, `?`, `"`, `<`, `>`, `|`, ` ` (space character), `,`, `#`
2443
- Indices prior to 7.0 could contain a colon (`:`), but that's been deprecated and won't be supported in 7.0+
2544
- Cannot start with `-`, `_`, `+`
2645
- Cannot be `.` or `..`
2746
- Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster)
47+
--
48+
49+
50+
[[indices-create-api-query-params]]
51+
==== {api-query-parms-title}
2852

29-
======================================================
53+
include::{docdir}/rest-api/common-parms.asciidoc[tag=include-type-name]
54+
55+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-wait-for-active-shards]
56+
57+
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
58+
59+
60+
[[indices-create-api-request-body]]
61+
==== {api-request-body-title}
62+
63+
`aliases`::
64+
(Optional, <<indices-aliases,alias object>>) Index aliases which include the
65+
index. See <<indices-aliases>>.
66+
67+
`mappings`::
68+
+
69+
--
70+
(Optional, <<mapping,mapping object>>) Mapping for fields in the index. If
71+
specified, this mapping can include:
72+
73+
* Field names
74+
* <<mapping-types,Field datatypes>>
75+
* <<mapping-params,Mapping parameters>>
76+
77+
See <<mapping>>.
78+
--
79+
80+
`settings`::
81+
(Optional, <<index-modules-settings,index setting object>>) Configuration
82+
options for the index. See <<index-modules-settings>>.
83+
84+
[[indices-create-api-example]]
85+
==== {api-examples-title}
3086

31-
[float]
3287
[[create-index-settings]]
33-
==== Index Settings
88+
===== Index settings
3489

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

3893
[source,js]
3994
--------------------------------------------------
40-
PUT twitter
95+
PUT /twitter
4196
{
4297
"settings" : {
4398
"index" : {
@@ -55,7 +110,7 @@ or more simplified
55110

56111
[source,js]
57112
--------------------------------------------------
58-
PUT twitter
113+
PUT /twitter
59114
{
60115
"settings" : {
61116
"number_of_shards" : 3,
@@ -73,16 +128,14 @@ For more information regarding all the different index level settings
73128
that can be set when creating an index, please check the
74129
<<index-modules,index modules>> section.
75130

76-
77-
[float]
78131
[[mappings]]
79-
==== Mappings
132+
===== Mappings
80133

81134
The create index API allows for providing a mapping definition:
82135

83136
[source,js]
84137
--------------------------------------------------
85-
PUT test
138+
PUT /test
86139
{
87140
"settings" : {
88141
"number_of_shards" : 1
@@ -100,15 +153,14 @@ NOTE: Before 7.0.0, the 'mappings' definition used to include a type name. Altho
100153
types in requests is now deprecated, a type can still be provided if the request parameter
101154
include_type_name is set. For more details, please see <<removal-of-types>>.
102155

103-
[float]
104156
[[create-index-aliases]]
105-
==== Aliases
157+
===== Aliases
106158

107159
The create index API allows also to provide a set of <<indices-aliases,aliases>>:
108160

109161
[source,js]
110162
--------------------------------------------------
111-
PUT test
163+
PUT /test
112164
{
113165
"aliases" : {
114166
"alias_1" : {},
@@ -123,9 +175,8 @@ PUT test
123175
--------------------------------------------------
124176
// CONSOLE
125177

126-
[float]
127178
[[create-index-wait-for-active-shards]]
128-
==== Wait For Active Shards
179+
===== Wait For active shards
129180

130181
By default, index creation will only return a response to the client when the primary copies of
131182
each shard have been started, or the request times out. The index creation response will indicate
@@ -158,7 +209,7 @@ the `wait_for_active_shards` value on all subsequent write operations):
158209

159210
[source,js]
160211
--------------------------------------------------
161-
PUT test
212+
PUT /test
162213
{
163214
"settings": {
164215
"index.write.wait_for_active_shards": "2"
@@ -172,7 +223,7 @@ or through the request parameter `wait_for_active_shards`:
172223

173224
[source,js]
174225
--------------------------------------------------
175-
PUT test?wait_for_active_shards=2
226+
PUT /test?wait_for_active_shards=2
176227
--------------------------------------------------
177228
// CONSOLE
178229
// TEST[skip:requires two nodes]

docs/reference/rest-api/common-parms.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,15 @@ end::doc-version-type[]
163163

164164
tag::doc-wait-for-active-shards[]
165165
`wait_for_active_shards`::
166+
+
167+
--
166168
(Optional, string) The number of shard copies that must be active before
167169
proceeding with the operation. Set to `all` or any positive integer up
168170
to the total number of shards in the index (`number_of_replicas+1`).
169171
Default: 1, the primary shard.
172+
173+
See <<index-wait-for-active-shards>>.
174+
--
170175
end::doc-wait-for-active-shards[]
171176

172177
tag::timeoutparms[]

0 commit comments

Comments
 (0)