Skip to content

Commit

Permalink
Merge remote-tracking branch 'elastic/master' into bring-your-own-clu…
Browse files Browse the repository at this point in the history
…ster

* elastic/master:
  Do not serialize basic license exp in x-pack info (elastic#30848)
  Change BWC version for VerifyRepositoryResponse (elastic#30796)
  [DOCS] Document index name limitations (elastic#30826)
  Harmonize include_defaults tests (elastic#30700)
  [TEST] Mute {p0=snapshot.get_repository/10_basic/Verify created repository} YAML test
  • Loading branch information
jasontedor committed May 25, 2018
2 parents 2b45ba9 + dcff63e commit 60f1c3b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 44 deletions.
50 changes: 27 additions & 23 deletions docs/reference/indices/create-index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
[[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.
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.
associated with it, defined in the body:

[source,js]
--------------------------------------------------
Expand All @@ -28,25 +51,6 @@ PUT twitter
<1> Default for `number_of_shards` is 1
<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]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
setup:
- do:
indices.create:
body:
settings:
index:
number_of_shards: 1
number_of_replicas: 1
index: test-index
---
Test retrieval of default settings:
- skip:
version: " - 6.3.99"
reason: include_defaults will not work in mixed-mode clusters containing nodes pre-6.4
- do:
indices.get_settings:
flat_settings: true
index: test-index
- is_false:
test-index.settings.index\.refresh_interval
- do:
indices.get_settings:
include_defaults: true
flat_settings: true
index: test-index
- match:
test-index.defaults.index\.refresh_interval: "1s"
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,3 @@ Test reset index settings:
indices.get_settings:
flat_settings: false
- is_false: test-index.settings.index\.refresh_interval

# Disabled until https://github.com/elastic/elasticsearch/pull/29229 is back-ported
# That PR changed the execution path of index settings default to be on the master
# until the PR is back-ported the old master will not return default settings.
#
# - do:
# indices.get_settings:
# include_defaults: true
# flat_settings: true
# index: test-index
# - match:
# test-index.defaults.index\.refresh_interval: "1s"
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ setup:

---
"Verify created repository":
- skip:
version: "all"
reason: AwaitsFix for https://github.com/elastic/elasticsearch/issues/30807
- do:
snapshot.verify_repository:
repository: test_repo_get_2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public VerifyRepositoryResponse(ClusterName clusterName, DiscoveryNode[] nodes)
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
this.nodes = in.readList(NodeView::new).stream().map(n -> n.convertToDiscoveryNode()).collect(Collectors.toList());
} else {
clusterName = new ClusterName(in);
Expand All @@ -151,7 +151,7 @@ public void readFrom(StreamInput in) throws IOException {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
out.writeList(getNodes());
} else {
clusterName.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ public License.Status getStatus() {

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return builder.startObject()
.field("uid", uid)
.field("type", type)
.field("mode", mode)
.field("status", status.label())
.timeField("expiry_date_in_millis", "expiry_date", expiryDate)
.endObject();
builder.startObject()
.field("uid", uid)
.field("type", type)
.field("mode", mode)
.field("status", status.label());
if (expiryDate != LicenseService.BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS) {
builder.timeField("expiry_date_in_millis", "expiry_date", expiryDate);
}
return builder.endObject();
}

public void writeTo(StreamOutput out) throws IOException {
Expand Down

0 comments on commit 60f1c3b

Please sign in to comment.