2015-12-30 11:50:46 -05:00
|
|
|
[[java-admin-indices-create-index]]
|
|
|
|
==== Create Index
|
|
|
|
|
|
|
|
Using an <<java-admin-indices,`IndicesAdminClient`>>, you can create an index with all default settings and no mapping:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
client.admin().indices().prepareCreate("twitter").get();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2015-12-30 11:50:46 -05:00
|
|
|
[[java-admin-indices-create-index-settings]]
|
|
|
|
===== Index Settings
|
|
|
|
|
|
|
|
Each index created can have specific settings associated with it.
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
client.admin().indices().prepareCreate("twitter")
|
|
|
|
.setSettings(Settings.builder() <1>
|
|
|
|
.put("index.number_of_shards", 3)
|
|
|
|
.put("index.number_of_replicas", 2)
|
|
|
|
)
|
|
|
|
.get(); <2>
|
|
|
|
--------------------------------------------------
|
|
|
|
<1> Settings for this index
|
|
|
|
<2> Execute the action and wait for the result
|
|
|
|
|