-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bulk, count, clear scroll, close PIT examples (#3510)
- Loading branch information
Showing
25 changed files
with
687 additions
and
271 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
specification/_global/bulk/examples/request/BulkRequestExample1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
summary: Multiple operations | ||
# method_request: POST _bulk | ||
description: Run `POST _bulk` to perform multiple operations. | ||
# type: request | ||
value: '{ "index" : { "_index" : "test", "_id" : "1" } } | ||
{ "field1" : "value1" } | ||
{ "delete" : { "_index" : "test", "_id" : "2" } } | ||
{ "create" : { "_index" : "test", "_id" : "3" } } | ||
{ "field1" : "value3" } | ||
{ "update" : {"_id" : "1", "_index" : "test"} } | ||
{ "doc" : {"field2" : "value2"} }' |
26 changes: 26 additions & 0 deletions
26
specification/_global/bulk/examples/request/BulkRequestExample2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
summary: Bulk updates | ||
# method_request: POST _bulk | ||
description: > | ||
When you run `POST _bulk` and use the `update` action, you can use `retry_on_conflict` as a field in the action itself (not in the extra payload line) to specify how many times an update should be retried in the case of a version conflict. | ||
# type: request | ||
value: | ||
'{ "update" : {"_id" : "1", "_index" : "index1", "retry_on_conflict" : 3} } | ||
{ "doc" : {"field" : "value"} } | ||
{ "update" : { "_id" : "0", "_index" : "index1", "retry_on_conflict" : 3} } | ||
{ "script" : { "source": "ctx._source.counter += params.param1", "lang" : "painless", | ||
"params" : {"param1" : 1}}, "upsert" : {"counter" : 1}} | ||
{ "update" : {"_id" : "2", "_index" : "index1", "retry_on_conflict" : 3} } | ||
{ "doc" : {"field" : "value"}, "doc_as_upsert" : true } | ||
{ "update" : {"_id" : "3", "_index" : "index1", "_source" : true} } | ||
{ "doc" : {"field" : "value"} } | ||
{ "update" : {"_id" : "4", "_index" : "index1"} } | ||
{ "doc" : {"field" : "value"}, "_source": true}' |
16 changes: 16 additions & 0 deletions
16
specification/_global/bulk/examples/request/BulkRequestExample3.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
summary: Filter for failed operations | ||
# method_request: POST /_bulk | ||
description: > | ||
To return only information about failed operations, run `POST /_bulk?filter_path=items.*.error`. | ||
# type: request | ||
value: '{ "update": {"_id": "5", "_index": "index1"} } | ||
{ "doc": {"my_field": "foo"} } | ||
{ "update": {"_id": "6", "_index": "index1"} } | ||
{ "doc": {"my_field": "foo"} } | ||
{ "create": {"_id": "7", "_index": "index1"} } | ||
{ "my_field": "foo" }' |
13 changes: 13 additions & 0 deletions
13
specification/_global/bulk/examples/request/BulkRequestExample4.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
summary: Dynamic templates | ||
method_request: POST /_bulk | ||
description: > | ||
Run `POST /_bulk` to perform a bulk request that consists of index and create actions with the `dynamic_templates` parameter. | ||
The bulk request creates two new fields `work_location` and `home_location` with type `geo_point` according to the `dynamic_templates` parameter. | ||
However, the `raw_location` field is created using default dynamic mapping rules, as a text field in that case since it is supplied as a string in the JSON document. | ||
# type: request | ||
value: "{ \"index\" : {\ | ||
\ \"_index\" : \"my_index\", \"_id\" : \"1\", \"dynamic_templates\": {\"work_location\"\ | ||
: \"geo_point\"}} }\n{ \"field\" : \"value1\", \"work_location\": \"41.12,-71.34\"\ | ||
, \"raw_location\": \"41.12,-71.34\"}\n{ \"create\" : { \"_index\" : \"my_index\"\ | ||
, \"_id\" : \"2\", \"dynamic_templates\": {\"home_location\": \"geo_point\"}} }\n\ | ||
{ \"field\" : \"value2\", \"home_location\": \"41.12,-71.34\"}" |
27 changes: 27 additions & 0 deletions
27
specification/_global/bulk/examples/response/BulkResponseExample1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
summary: Multiple successful operations | ||
# description: '' | ||
# type: response | ||
# response_code: '' | ||
value: | ||
"{\n \"took\": 30,\n \"errors\": false,\n \"items\": [\n {\n \ | ||
\ \"index\": {\n \"_index\": \"test\",\n \"_id\": \"\ | ||
1\",\n \"_version\": 1,\n \"result\": \"created\",\n \ | ||
\ \"_shards\": {\n \"total\": 2,\n \"successful\"\ | ||
: 1,\n \"failed\": 0\n },\n \"status\": 201,\n\ | ||
\ \"_seq_no\" : 0,\n \"_primary_term\": 1\n }\n \ | ||
\ },\n {\n \"delete\": {\n \"_index\": \"test\",\n \ | ||
\ \"_id\": \"2\",\n \"_version\": 1,\n \"result\"\ | ||
: \"not_found\",\n \"_shards\": {\n \"total\": 2,\n \ | ||
\ \"successful\": 1,\n \"failed\": 0\n },\n\ | ||
\ \"status\": 404,\n \"_seq_no\" : 1,\n \"_primary_term\"\ | ||
\ : 2\n }\n },\n {\n \"create\": {\n \"_index\"\ | ||
: \"test\",\n \"_id\": \"3\",\n \"_version\": 1,\n \ | ||
\ \"result\": \"created\",\n \"_shards\": {\n \"total\"\ | ||
: 2,\n \"successful\": 1,\n \"failed\": 0\n \ | ||
\ },\n \"status\": 201,\n \"_seq_no\" : 2,\n \ | ||
\ \"_primary_term\" : 3\n }\n },\n {\n \"update\": {\n\ | ||
\ \"_index\": \"test\",\n \"_id\": \"1\",\n \"\ | ||
_version\": 2,\n \"result\": \"updated\",\n \"_shards\": {\n\ | ||
\ \"total\": 2,\n \"successful\": 1,\n \ | ||
\ \"failed\": 0\n },\n \"status\": 200,\n \"\ | ||
_seq_no\" : 3,\n \"_primary_term\" : 4\n }\n }\n ]\n}" |
24 changes: 24 additions & 0 deletions
24
specification/_global/bulk/examples/response/BulkResponseExample2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
summary: Failed actions | ||
description: > | ||
If you run `POST /_bulk` with operations that update non-existent documents, the operations cannot complete successfully. | ||
The API returns a response with an `errors` property value `true`. | ||
The response also includes an error object for any failed operations. | ||
The error object contains additional information about the failure, such as the error type and reason. | ||
# type: response | ||
# response_code: '' | ||
value: | ||
"{\n \"took\": 486,\n \"errors\": true,\n \"items\": [\n {\n \"\ | ||
update\": {\n \"_index\": \"index1\",\n \"_id\": \"5\",\n \"\ | ||
status\": 404,\n \"error\": {\n \"type\": \"document_missing_exception\"\ | ||
,\n \"reason\": \"[5]: document missing\",\n \"index_uuid\": \"\ | ||
aAsFqTI0Tc2W0LCWgPNrOA\",\n \"shard\": \"0\",\n \"index\": \"\ | ||
index1\"\n }\n }\n },\n {\n \"update\": {\n \"_index\"\ | ||
: \"index1\",\n \"_id\": \"6\",\n \"status\": 404,\n \"error\"\ | ||
: {\n \"type\": \"document_missing_exception\",\n \"reason\":\ | ||
\ \"[6]: document missing\",\n \"index_uuid\": \"aAsFqTI0Tc2W0LCWgPNrOA\"\ | ||
,\n \"shard\": \"0\",\n \"index\": \"index1\"\n }\n \ | ||
\ }\n },\n {\n \"create\": {\n \"_index\": \"index1\",\n \ | ||
\ \"_id\": \"7\",\n \"_version\": 1,\n \"result\": \"created\"\ | ||
,\n \"_shards\": {\n \"total\": 2,\n \"successful\": 1,\n\ | ||
\ \"failed\": 0\n },\n \"_seq_no\": 0,\n \"_primary_term\"\ | ||
: 1,\n \"status\": 201\n }\n }\n ]\n}" |
14 changes: 14 additions & 0 deletions
14
specification/_global/bulk/examples/response/BulkResponseExample3.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
summary: Filter for failed operations | ||
description: > | ||
An example response from `POST /_bulk?filter_path=items.*.error`, which returns only information about failed operations. | ||
# type: response | ||
# response_code: '' | ||
value: | ||
"{\n \"items\": [\n {\n \"update\": {\n \"error\": {\n \ | ||
\ \"type\": \"document_missing_exception\",\n \"reason\": \"[5]: document\ | ||
\ missing\",\n \"index_uuid\": \"aAsFqTI0Tc2W0LCWgPNrOA\",\n \"\ | ||
shard\": \"0\",\n \"index\": \"index1\"\n }\n }\n },\n \ | ||
\ {\n \"update\": {\n \"error\": {\n \"type\": \"document_missing_exception\"\ | ||
,\n \"reason\": \"[6]: document missing\",\n \"index_uuid\": \"\ | ||
aAsFqTI0Tc2W0LCWgPNrOA\",\n \"shard\": \"0\",\n \"index\": \"\ | ||
index1\"\n }\n }\n }\n ]\n}" |
Oops, something went wrong.