Skip to content

Commit 978ce9e

Browse files
lcawlkcm
authored andcommitted
[DOCS] Clarifies examples in reindex and task APIs (#33143)
1 parent 46708f1 commit 978ce9e

File tree

4 files changed

+54
-58
lines changed

4 files changed

+54
-58
lines changed

docs/reference/cluster/tasks.asciidoc

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ GET _tasks?nodes=nodeId1,nodeId2 <2>
1616
GET _tasks?nodes=nodeId1,nodeId2&actions=cluster:* <3>
1717
--------------------------------------------------
1818
// CONSOLE
19+
// TEST[skip:No tasks to retrieve]
1920

2021
<1> Retrieves all tasks currently running on all nodes in the cluster.
2122
<2> Retrieves all tasks running on nodes `nodeId1` and `nodeId2`. See <<cluster-nodes>> for more info about how to select individual nodes.
@@ -57,31 +58,29 @@ The result will look similar to the following:
5758
}
5859
}
5960
--------------------------------------------------
60-
// NOTCONSOLE
61-
// We can't test tasks output
61+
// TESTRESPONSE
6262

63-
It is also possible to retrieve information for a particular task:
63+
It is also possible to retrieve information for a particular task. The following
64+
example retrieves information about task `oTUltX4IQMOUUVeiohTt8A:124`:
6465

6566
[source,js]
6667
--------------------------------------------------
67-
GET _tasks/task_id <1>
68+
GET _tasks/oTUltX4IQMOUUVeiohTt8A:124
6869
--------------------------------------------------
6970
// CONSOLE
70-
// TEST[s/task_id/node_id:1/]
7171
// TEST[catch:missing]
7272

73-
<1> This will return a 404 if the task isn't found.
73+
If the task isn't found, the API returns a 404.
7474

75-
Or to retrieve all children of a particular task:
75+
To retrieve all children of a particular task:
7676

7777
[source,js]
7878
--------------------------------------------------
79-
GET _tasks?parent_task_id=parent_task_id <1>
79+
GET _tasks?parent_task_id=oTUltX4IQMOUUVeiohTt8A:123
8080
--------------------------------------------------
8181
// CONSOLE
82-
// TEST[s/=parent_task_id/=node_id:1/]
8382

84-
<1> This won't return a 404 if the parent isn't found.
83+
If the parent isn't found, the API does not return a 404.
8584

8685
You can also use the `detailed` request parameter to get more information about
8786
the running tasks. This is useful for telling one task from another but is more
@@ -93,8 +92,9 @@ request parameter:
9392
GET _tasks?actions=*search&detailed
9493
--------------------------------------------------
9594
// CONSOLE
95+
// TEST[skip:No tasks to retrieve]
9696

97-
might look like:
97+
The results might look like:
9898

9999
[source,js]
100100
--------------------------------------------------
@@ -121,8 +121,7 @@ might look like:
121121
}
122122
}
123123
--------------------------------------------------
124-
// NOTCONSOLE
125-
// We can't test tasks output
124+
// TESTRESPONSE
126125

127126
The new `description` field contains human readable text that identifies the
128127
particular request that the task is performing such as identifying the search
@@ -167,14 +166,14 @@ GET _cat/tasks?detailed
167166
[[task-cancellation]]
168167
=== Task Cancellation
169168

170-
If a long-running task supports cancellation, it can be cancelled by the following command:
169+
If a long-running task supports cancellation, it can be cancelled with the cancel
170+
tasks API. The following example cancels task `oTUltX4IQMOUUVeiohTt8A:12345`:
171171

172172
[source,js]
173173
--------------------------------------------------
174-
POST _tasks/node_id:task_id/_cancel
174+
POST _tasks/oTUltX4IQMOUUVeiohTt8A:12345/_cancel
175175
--------------------------------------------------
176176
// CONSOLE
177-
// TEST[s/task_id/1/]
178177

179178
The task cancellation command supports the same task selection parameters as the list tasks command, so multiple tasks
180179
can be cancelled at the same time. For example, the following command will cancel all reindex tasks running on the
@@ -217,7 +216,7 @@ a the client that started them:
217216
--------------------------------------------------
218217
curl -i -H "X-Opaque-Id: 123456" "http://localhost:9200/_tasks?group_by=parents"
219218
--------------------------------------------------
220-
// NOTCONSOLE
219+
//NOTCONSOLE
221220

222221
The result will look similar to the following:
223222

@@ -260,8 +259,7 @@ content-length: 831
260259
}
261260
}
262261
--------------------------------------------------
263-
// NOTCONSOLE
264-
262+
//NOTCONSOLE
265263
<1> id as a part of the response header
266264
<2> id for the tasks that was initiated by the REST request
267265
<3> the child task of the task initiated by the REST request

docs/reference/docs/delete-by-query.asciidoc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ You can fetch the status of any running delete-by-query requests with the
304304
GET _tasks?detailed=true&actions=*/delete/byquery
305305
--------------------------------------------------
306306
// CONSOLE
307+
// TEST[skip:No tasks to retrieve]
307308

308309
The responses looks like:
309310

@@ -344,9 +345,7 @@ The responses looks like:
344345
}
345346
}
346347
--------------------------------------------------
347-
// NOTCONSOLE
348-
// We can't test tasks output
349-
348+
// TESTRESPONSE
350349
<1> this object contains the actual status. It is just like the response json
351350
with the important addition of the `total` field. `total` is the total number
352351
of operations that the reindex expects to perform. You can estimate the
@@ -357,10 +356,9 @@ With the task id you can look up the task directly:
357356

358357
[source,js]
359358
--------------------------------------------------
360-
GET /_tasks/task_id
359+
GET /_tasks/r1A2WoRbTwKZ516z6NEs5A:36619
361360
--------------------------------------------------
362361
// CONSOLE
363-
// TEST[s/task_id/node_id:1/]
364362
// TEST[catch:missing]
365363

366364
The advantage of this API is that it integrates with `wait_for_completion=false`
@@ -375,16 +373,15 @@ you to delete that document.
375373
[[docs-delete-by-query-cancel-task-api]]
376374
=== Works with the Cancel Task API
377375

378-
Any Delete By Query can be canceled using the <<tasks,Task Cancel API>>:
376+
Any Delete By Query can be canceled using the <<tasks,task cancel API>>:
379377

380378
[source,js]
381379
--------------------------------------------------
382-
POST _tasks/task_id/_cancel
380+
POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
383381
--------------------------------------------------
384-
// TEST[s/task_id/node_id:1/]
385382
// CONSOLE
386383

387-
The `task_id` can be found using the tasks API above.
384+
The task ID can be found using the <<tasks,tasks API>>.
388385

389386
Cancellation should happen quickly but might take a few seconds. The task status
390387
API above will continue to list the task until it is wakes to cancel itself.
@@ -399,12 +396,11 @@ using the `_rethrottle` API:
399396

400397
[source,js]
401398
--------------------------------------------------
402-
POST _delete_by_query/task_id/_rethrottle?requests_per_second=-1
399+
POST _delete_by_query/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1
403400
--------------------------------------------------
404-
// TEST[s/task_id/node_id:1/]
405401
// CONSOLE
406402

407-
The `task_id` can be found using the tasks API above.
403+
The task ID can be found using the <<tasks,tasks API>>.
408404

409405
Just like when setting it on the `_delete_by_query` API `requests_per_second`
410406
can be either `-1` to disable throttling or any decimal number

docs/reference/docs/reindex.asciidoc

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ You can fetch the status of all running reindex requests with the
692692
GET _tasks?detailed=true&actions=*reindex
693693
--------------------------------------------------
694694
// CONSOLE
695+
// TEST[skip:No tasks to retrieve]
695696

696697
The response looks like:
697698

@@ -726,32 +727,36 @@ The response looks like:
726727
"bulk": 0,
727728
"search": 0
728729
},
729-
"throttled_millis": 0
730+
"throttled_millis": 0,
731+
"requests_per_second": -1,
732+
"throttled_until_millis": 0
730733
},
731-
"description" : ""
734+
"description" : "",
735+
"start_time_in_millis": 1535149899665,
736+
"running_time_in_nanos": 5926916792,
737+
"cancellable": true,
738+
"headers": {}
732739
}
733740
}
734741
}
735742
}
736743
}
737744
--------------------------------------------------
738-
// NOTCONSOLE
739-
// We can't test tasks output
740-
745+
// TESTRESPONSE
741746
<1> this object contains the actual status. It is identical to the response JSON
742747
except for the important addition of the `total` field. `total` is the total number
743748
of operations that the `_reindex` expects to perform. You can estimate the
744749
progress by adding the `updated`, `created`, and `deleted` fields. The request
745750
will finish when their sum is equal to the `total` field.
746751

747-
With the task id you can look up the task directly:
752+
With the task id you can look up the task directly. The following example
753+
retrieves information about the task `r1A2WoRbTwKZ516z6NEs5A:36619`:
748754

749755
[source,js]
750756
--------------------------------------------------
751-
GET /_tasks/task_id
757+
GET /_tasks/r1A2WoRbTwKZ516z6NEs5A:36619
752758
--------------------------------------------------
753759
// CONSOLE
754-
// TEST[s/task_id/node_id:1/]
755760
// TEST[catch:missing]
756761

757762
The advantage of this API is that it integrates with `wait_for_completion=false`
@@ -766,16 +771,16 @@ you to delete that document.
766771
[[docs-reindex-cancel-task-api]]
767772
=== Works with the Cancel Task API
768773

769-
Any Reindex can be canceled using the <<tasks,Task Cancel API>>:
774+
Any Reindex can be canceled using the <<task-cancellation,Task Cancel API>>. For
775+
example:
770776

771777
[source,js]
772778
--------------------------------------------------
773-
POST _tasks/task_id/_cancel
779+
POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
774780
--------------------------------------------------
775781
// CONSOLE
776-
// TEST[s/task_id/node_id:1/]
777782

778-
The `task_id` can be found using the Tasks API.
783+
The task ID can be found using the <<tasks,Tasks API>>.
779784

780785
Cancelation should happen quickly but might take a few seconds. The Tasks
781786
API will continue to list the task until it wakes to cancel itself.
@@ -790,12 +795,11 @@ the `_rethrottle` API:
790795

791796
[source,js]
792797
--------------------------------------------------
793-
POST _reindex/task_id/_rethrottle?requests_per_second=-1
798+
POST _reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1
794799
--------------------------------------------------
795800
// CONSOLE
796-
// TEST[s/task_id/node_id:1/]
797801

798-
The `task_id` can be found using the Tasks API above.
802+
The task ID can be found using the <<tasks,tasks API>>.
799803

800804
Just like when setting it on the Reindex API, `requests_per_second`
801805
can be either `-1` to disable throttling or any decimal number

docs/reference/docs/update-by-query.asciidoc

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ You can fetch the status of all running update-by-query requests with the
359359
GET _tasks?detailed=true&actions=*byquery
360360
--------------------------------------------------
361361
// CONSOLE
362+
// TEST[skip:No tasks to retrieve]
362363

363364
The responses looks like:
364365

@@ -392,7 +393,7 @@ The responses looks like:
392393
"retries": {
393394
"bulk": 0,
394395
"search": 0
395-
}
396+
},
396397
"throttled_millis": 0
397398
},
398399
"description" : ""
@@ -402,23 +403,22 @@ The responses looks like:
402403
}
403404
}
404405
--------------------------------------------------
405-
// NOTCONSOLE
406-
// We can't test tasks output
406+
// TESTRESPONSE
407407

408408
<1> this object contains the actual status. It is just like the response json
409409
with the important addition of the `total` field. `total` is the total number
410410
of operations that the reindex expects to perform. You can estimate the
411411
progress by adding the `updated`, `created`, and `deleted` fields. The request
412412
will finish when their sum is equal to the `total` field.
413413

414-
With the task id you can look up the task directly:
414+
With the task id you can look up the task directly. The following example
415+
retrieves information about task `r1A2WoRbTwKZ516z6NEs5A:36619`:
415416

416417
[source,js]
417418
--------------------------------------------------
418-
GET /_tasks/task_id
419+
GET /_tasks/r1A2WoRbTwKZ516z6NEs5A:36619
419420
--------------------------------------------------
420421
// CONSOLE
421-
// TEST[s/task_id/node_id:1/]
422422
// TEST[catch:missing]
423423

424424
The advantage of this API is that it integrates with `wait_for_completion=false`
@@ -437,12 +437,11 @@ Any Update By Query can be canceled using the <<tasks,Task Cancel API>>:
437437

438438
[source,js]
439439
--------------------------------------------------
440-
POST _tasks/task_id/_cancel
440+
POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
441441
--------------------------------------------------
442442
// CONSOLE
443-
// TEST[s/task_id/node_id:1/]
444443

445-
The `task_id` can be found using the tasks API above.
444+
The task ID can be found using the <<tasks,tasks API>>.
446445

447446
Cancellation should happen quickly but might take a few seconds. The task status
448447
API above will continue to list the task until it is wakes to cancel itself.
@@ -457,12 +456,11 @@ using the `_rethrottle` API:
457456

458457
[source,js]
459458
--------------------------------------------------
460-
POST _update_by_query/task_id/_rethrottle?requests_per_second=-1
459+
POST _update_by_query/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1
461460
--------------------------------------------------
462461
// CONSOLE
463-
// TEST[s/task_id/node_id:1/]
464462

465-
The `task_id` can be found using the tasks API above.
463+
The task ID can be found using the <<tasks, tasks API>>.
466464

467465
Just like when setting it on the `_update_by_query` API `requests_per_second`
468466
can be either `-1` to disable throttling or any decimal number

0 commit comments

Comments
 (0)