Add CONSOLE to more docs

Relates to #18160
This commit is contained in:
Nik Everett 2016-09-01 17:08:18 -04:00
parent 5fe4cb6adc
commit c8b984aee9
3 changed files with 45 additions and 26 deletions

View File

@ -65,18 +65,18 @@ buildRestTests.docs = fileTree(projectDir) {
Closure setupTwitter = { String name, int count -> Closure setupTwitter = { String name, int count ->
buildRestTests.setups[name] = ''' buildRestTests.setups[name] = '''
- do: - do:
indices.create: indices.create:
index: twitter index: twitter
body: body:
settings: settings:
number_of_shards: 1 number_of_shards: 1
number_of_replicas: 1 number_of_replicas: 1
- do: - do:
bulk: bulk:
index: twitter index: twitter
type: tweet type: tweet
refresh: true refresh: true
body: |''' body: |'''
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
String user, text String user, text
if (i == 0) { if (i == 0) {
@ -87,12 +87,13 @@ Closure setupTwitter = { String name, int count ->
text = "some message with the number $i" text = "some message with the number $i"
} }
buildRestTests.setups[name] += """ buildRestTests.setups[name] += """
{"index":{"_id": "$i"}} {"index":{"_id": "$i"}}
{"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}""" {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
} }
} }
setupTwitter('twitter', 5) setupTwitter('twitter', 5)
setupTwitter('big_twitter', 120) setupTwitter('big_twitter', 120)
setupTwitter('huge_twitter', 1200)
buildRestTests.setups['host'] = ''' buildRestTests.setups['host'] = '''
# Fetch the http host. We use the host of the master because we know there will always be a master. # Fetch the http host. We use the host of the master because we know there will always be a master.

View File

@ -9,8 +9,10 @@ refresh is scheduled periodically.
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
$ curl -XPOST 'http://localhost:9200/twitter/_refresh' POST /twitter/_refresh
-------------------------------------------------- --------------------------------------------------
// CONSOLE
// TEST[setup:twitter]
[float] [float]
=== Multi Index === Multi Index
@ -20,7 +22,9 @@ call, or even on `_all` the indices.
[source,js] [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/]

View File

@ -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": { "conditions": {
"max_age": "7d", "max_age": "7d",
@ -28,6 +30,8 @@ POST logs_write/_rollover <2>
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE // 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`. <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 <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 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] [source,js]
-------------------------------------------------- --------------------------------------------------
{ {
"acknowledged": true,
"shards_acknowledged": true,
"old_index": "logs-000001", "old_index": "logs-000001",
"new_index": "logs-000002", "new_index": "logs-000002",
"rolled_over": true, <1> "rolled_over": true, <1>
@ -48,6 +54,7 @@ The above request might return the following response:
} }
} }
-------------------------------------------------- --------------------------------------------------
// TESTRESPONSE
<1> Whether the index was rolled over. <1> Whether the index was rolled over.
<2> Whether the rollover was dry run. <2> Whether the rollover was dry run.
<3> The result of each condition. <3> The result of each condition.
@ -65,9 +72,16 @@ the new index as follows:
[source,js] [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] [float]
=== Defining the new index === 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 The settings, mappings, and aliases for the new index are taken from any
matching <<indices-templates,index templates>>. Additionally, you can specify matching <<indices-templates,index templates>>. Additionally, you can specify
`settings`, `mappings`, and `aliases` in the body of the request, just like the `settings`, `mappings`, and `aliases` in the body of the request, just like the
<<indices-create-index,create index>> API. Values specified in the request <<indices-create-index,create index>> API. Values specified in the request
override any values set in matching index templates. For example, the following override any values set in matching index templates. For example, the following
`rollover` request overrides the `index.number_of_shards` setting: `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" : { "conditions" : {
"max_age": "7d", "max_age": "7d",
"max_docs": 1000 "max_docs": 1000
}, },
"settings": { "settings": {
"index.number_of_shards": 2 "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" : { "conditions" : {
"max_age": "7d", "max_age": "7d",
@ -129,6 +143,6 @@ POST logs_write/_rollover?dry_run
[float] [float]
=== Wait For Active Shards === Wait For Active Shards
Because the rollover operation creates a new index to rollover to, the Because the rollover operation creates a new index to rollover to, the
<<create-index-wait-for-active-shards,wait for active shards>> setting on <<create-index-wait-for-active-shards,wait for active shards>> setting on
index creation applies to the rollover action as well. index creation applies to the rollover action as well.