2018-11-27 20:40:49 -05:00
|
|
|
--
|
|
|
|
:api: create-index
|
|
|
|
:request: CreateIndexRequest
|
|
|
|
:response: CreateIndexResponse
|
|
|
|
--
|
|
|
|
|
|
|
|
[id="{upid}-{api}"]
|
2017-12-07 05:39:59 -05:00
|
|
|
=== Create Index API
|
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
[id="{upid}-{api}-request"]
|
2017-12-07 05:39:59 -05:00
|
|
|
==== Create Index Request
|
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
A +{request}+ requires an `index` argument:
|
2017-12-07 05:39:59 -05:00
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The index to create
|
|
|
|
|
|
|
|
==== Index settings
|
|
|
|
Each index created can have specific settings associated with it.
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request-settings]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Settings for this index
|
|
|
|
|
2018-02-20 09:58:58 -05:00
|
|
|
[[java-rest-high-create-index-request-mappings]]
|
2017-12-07 05:39:59 -05:00
|
|
|
==== Index mappings
|
|
|
|
An index may be created with mappings for its document types
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request-mappings]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The type to define
|
|
|
|
<2> The mapping for this type, provided as a JSON string
|
|
|
|
|
2018-02-02 04:32:24 -05:00
|
|
|
The mapping source can be provided in different ways in addition to the
|
|
|
|
`String` example shown above:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-mappings-map]
|
2018-02-02 04:32:24 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Mapping source provided as a `Map` which gets automatically converted
|
|
|
|
to JSON format
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-mappings-xcontent]
|
2018-02-02 04:32:24 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Mapping source provided as an `XContentBuilder` object, the Elasticsearch
|
|
|
|
built-in helpers to generate JSON content
|
|
|
|
|
2017-12-07 05:39:59 -05:00
|
|
|
==== Index aliases
|
|
|
|
Aliases can be set at index creation time
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request-aliases]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The alias to define
|
|
|
|
|
2018-02-02 04:32:24 -05:00
|
|
|
==== Providing the whole source
|
|
|
|
|
|
|
|
The whole source including all of its sections (mappings, settings and aliases)
|
|
|
|
can also be provided:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-whole-source]
|
2018-02-02 04:32:24 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The source provided as a JSON string. It can also be provided as a `Map`
|
|
|
|
or an `XContentBuilder`.
|
|
|
|
|
2017-12-07 05:39:59 -05:00
|
|
|
==== Optional arguments
|
|
|
|
The following arguments can optionally be provided:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request-timeout]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Timeout to wait for the all the nodes to acknowledge the index creation as a `TimeValue`
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request-masterTimeout]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Timeout to connect to the master node as a `TimeValue`
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request-waitForActiveShards]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
2018-01-17 05:47:08 -05:00
|
|
|
<1> The number of active shard copies to wait for before the create index API returns a
|
2018-02-20 09:58:58 -05:00
|
|
|
response, as an `int`
|
2018-01-17 05:47:08 -05:00
|
|
|
<2> The number of active shard copies to wait for before the create index API returns a
|
2018-02-20 09:58:58 -05:00
|
|
|
response, as an `ActiveShardCount`
|
2017-12-07 05:39:59 -05:00
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
include::../execution.asciidoc[]
|
2017-12-07 05:39:59 -05:00
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
[id="{upid}-{api}-response"]
|
2017-12-07 05:39:59 -05:00
|
|
|
==== Create Index Response
|
|
|
|
|
2018-11-27 20:40:49 -05:00
|
|
|
The returned +{response}+ allows to retrieve information about the executed
|
2017-12-07 05:39:59 -05:00
|
|
|
operation as follows:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-11-27 20:40:49 -05:00
|
|
|
include-tagged::{doc-tests-file}[{api}-response]
|
2017-12-07 05:39:59 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Indicates whether all of the nodes have acknowledged the request
|
|
|
|
<2> Indicates whether the requisite number of shard copies were started for each shard in the index before timing out
|