From c8b984aee9cad0d6e652412905b116f08b737c56 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 1 Sep 2016 17:08:18 -0400 Subject: [PATCH] Add CONSOLE to more docs Relates to #18160 --- docs/build.gradle | 27 ++++++++------- docs/reference/indices/refresh.asciidoc | 10 ++++-- .../reference/indices/rollover-index.asciidoc | 34 +++++++++++++------ 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/docs/build.gradle b/docs/build.gradle index caf7cfea01e..d930dfb5b60 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -65,18 +65,18 @@ buildRestTests.docs = fileTree(projectDir) { Closure setupTwitter = { String name, int count -> buildRestTests.setups[name] = ''' - do: - indices.create: - index: twitter - body: - settings: - number_of_shards: 1 - number_of_replicas: 1 + indices.create: + index: twitter + body: + settings: + number_of_shards: 1 + number_of_replicas: 1 - do: - bulk: - index: twitter - type: tweet - refresh: true - body: |''' + bulk: + index: twitter + type: tweet + refresh: true + body: |''' for (int i = 0; i < count; i++) { String user, text if (i == 0) { @@ -87,12 +87,13 @@ Closure setupTwitter = { String name, int count -> text = "some message with the number $i" } buildRestTests.setups[name] += """ - {"index":{"_id": "$i"}} - {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}""" + {"index":{"_id": "$i"}} + {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}""" } } setupTwitter('twitter', 5) setupTwitter('big_twitter', 120) +setupTwitter('huge_twitter', 1200) buildRestTests.setups['host'] = ''' # Fetch the http host. We use the host of the master because we know there will always be a master. diff --git a/docs/reference/indices/refresh.asciidoc b/docs/reference/indices/refresh.asciidoc index bbc1f20f409..1e27ace3625 100644 --- a/docs/reference/indices/refresh.asciidoc +++ b/docs/reference/indices/refresh.asciidoc @@ -9,8 +9,10 @@ refresh is scheduled periodically. [source,js] -------------------------------------------------- -$ curl -XPOST 'http://localhost:9200/twitter/_refresh' +POST /twitter/_refresh -------------------------------------------------- +// CONSOLE +// TEST[setup:twitter] [float] === Multi Index @@ -20,7 +22,9 @@ call, or even on `_all` the indices. [source,js] -------------------------------------------------- -$ curl -XPOST 'http://localhost:9200/kimchy,elasticsearch/_refresh' +POST /kimchy,elasticsearch/_refresh -$ curl -XPOST 'http://localhost:9200/_refresh' +POST /_refresh -------------------------------------------------- +// CONSOLE +// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/] diff --git a/docs/reference/indices/rollover-index.asciidoc b/docs/reference/indices/rollover-index.asciidoc index b12d93bb4b8..5e3f744ebaf 100644 --- a/docs/reference/indices/rollover-index.asciidoc +++ b/docs/reference/indices/rollover-index.asciidoc @@ -19,7 +19,9 @@ PUT /logs-000001 <1> } } -POST logs_write/_rollover <2> +# Add > 1000 documents to logs-000001 + +POST /logs_write/_rollover <2> { "conditions": { "max_age": "7d", @@ -28,6 +30,8 @@ POST logs_write/_rollover <2> } -------------------------------------------------- // CONSOLE +// TEST[setup:huge_twitter] +// TEST[s/# Add > 1000 documents to logs-000001/POST _reindex?refresh\n{"source":{"index":"twitter"},"dest":{"index":"logs-000001"}}/] <1> Creates an index called `logs-0000001` with the alias `logs_write`. <2> If the index pointed to by `logs_write` was created 7 or more days ago, or contains 1,000 or more documents, then the `logs-0002` index is created @@ -38,6 +42,8 @@ The above request might return the following response: [source,js] -------------------------------------------------- { + "acknowledged": true, + "shards_acknowledged": true, "old_index": "logs-000001", "new_index": "logs-000002", "rolled_over": true, <1> @@ -48,6 +54,7 @@ The above request might return the following response: } } -------------------------------------------------- +// TESTRESPONSE <1> Whether the index was rolled over. <2> Whether the rollover was dry run. <3> The result of each condition. @@ -65,9 +72,16 @@ the new index as follows: [source,js] -------------------------------------------------- -POST my_alias/_rollover/my_new_index_name -{...} +POST /my_alias/_rollover/my_new_index_name +{ + "conditions": { + "max_age": "7d", + "max_docs": 1000 + } +} -------------------------------------------------- +// CONSOLE +// TEST[s/^/PUT my_old_index_name\nPUT my_old_index_name\/_alias\/my_alias\n/] [float] === Defining the new index @@ -75,7 +89,7 @@ POST my_alias/_rollover/my_new_index_name The settings, mappings, and aliases for the new index are taken from any matching <>. Additionally, you can specify `settings`, `mappings`, and `aliases` in the body of the request, just like the -<> API. Values specified in the request +<> API. Values specified in the request override any values set in matching index templates. For example, the following `rollover` request overrides the `index.number_of_shards` setting: @@ -88,14 +102,14 @@ PUT /logs-000001 } } -POST logs_write/_rollover +POST /logs_write/_rollover { "conditions" : { "max_age": "7d", "max_docs": 1000 }, - "settings": { - "index.number_of_shards": 2 + "settings": { + "index.number_of_shards": 2 } } -------------------------------------------------- @@ -116,7 +130,7 @@ PUT /logs-000001 } } -POST logs_write/_rollover?dry_run +POST /logs_write/_rollover?dry_run { "conditions" : { "max_age": "7d", @@ -129,6 +143,6 @@ POST logs_write/_rollover?dry_run [float] === Wait For Active Shards -Because the rollover operation creates a new index to rollover to, the -<> setting on +Because the rollover operation creates a new index to rollover to, the +<> setting on index creation applies to the rollover action as well.