Skip to content

Commit b3cccd2

Browse files
authored
Validate the 'update' API
1 parent 0beffbb commit b3cccd2

File tree

4 files changed

+112
-23
lines changed

4 files changed

+112
-23
lines changed

output/schema/schema.json

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12253,7 +12253,7 @@
1225312253
"namespace": "_global.update"
1225412254
},
1225512255
"since": "0.0.0",
12256-
"stability": "TODO",
12256+
"stability": "stable",
1225712257
"urls": [
1225812258
{
1225912259
"methods": [
@@ -28231,8 +28231,10 @@
2823128231
"kind": "properties",
2823228232
"properties": [
2823328233
{
28234+
"description": "Set to false to disable setting 'result' in the response to 'noop' if no change to the document occurred.",
2823428235
"name": "detect_noop",
2823528236
"required": false,
28237+
"serverDefault": true,
2823628238
"type": {
2823728239
"kind": "instance_of",
2823828240
"type": {
@@ -28242,6 +28244,7 @@
2824228244
}
2824328245
},
2824428246
{
28247+
"description": "A partial update to an existing document.",
2824528248
"name": "doc",
2824628249
"required": false,
2824728250
"type": {
@@ -28253,8 +28256,10 @@
2825328256
}
2825428257
},
2825528258
{
28259+
"description": "Set to true to use the contents of 'doc' as the value of 'upsert'",
2825628260
"name": "doc_as_upsert",
2825728261
"required": false,
28262+
"serverDefault": false,
2825828263
"type": {
2825928264
"kind": "instance_of",
2826028265
"type": {
@@ -28264,6 +28269,7 @@
2826428269
}
2826528270
},
2826628271
{
28272+
"description": "Script to execute to update the document.",
2826728273
"name": "script",
2826828274
"required": false,
2826928275
"type": {
@@ -28275,8 +28281,10 @@
2827528281
}
2827628282
},
2827728283
{
28284+
"description": "Set to true to execute the script whether or not the document exists.",
2827828285
"name": "scripted_upsert",
2827928286
"required": false,
28287+
"serverDefault": false,
2828028288
"type": {
2828128289
"kind": "instance_of",
2828228290
"type": {
@@ -28286,8 +28294,10 @@
2828628294
}
2828728295
},
2828828296
{
28297+
"description": "Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve.",
2828928298
"name": "_source",
2829028299
"required": false,
28300+
"serverDefault": "true",
2829128301
"type": {
2829228302
"items": [
2829328303
{
@@ -28309,6 +28319,7 @@
2830928319
}
2831028320
},
2831128321
{
28322+
"description": "If the document does not already exist, the contents of 'upsert' are inserted as a new document. If the document exists, the 'script' is executed.",
2831228323
"name": "upsert",
2831328324
"required": false,
2831428325
"type": {
@@ -28379,6 +28390,7 @@
2837928390
],
2838028391
"query": [
2838128392
{
28393+
"description": "Only perform the operation if the document has this primary term.",
2838228394
"name": "if_primary_term",
2838328395
"required": false,
2838428396
"type": {
@@ -28390,6 +28402,7 @@
2839028402
}
2839128403
},
2839228404
{
28405+
"description": "Only perform the operation if the document has this sequence number.",
2839328406
"name": "if_seq_no",
2839428407
"required": false,
2839528408
"type": {
@@ -28401,8 +28414,10 @@
2840128414
}
2840228415
},
2840328416
{
28417+
"description": "The script language.",
2840428418
"name": "lang",
2840528419
"required": false,
28420+
"serverDefault": "painless",
2840628421
"type": {
2840728422
"kind": "instance_of",
2840828423
"type": {
@@ -28412,8 +28427,10 @@
2841228427
}
2841328428
},
2841428429
{
28430+
"description": "If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search, if 'wait_for' then wait for a refresh to make this operation visible to search, if 'false' do nothing with refreshes.",
2841528431
"name": "refresh",
2841628432
"required": false,
28433+
"serverDefault": "false",
2841728434
"type": {
2841828435
"kind": "instance_of",
2841928436
"type": {
@@ -28423,8 +28440,10 @@
2842328440
}
2842428441
},
2842528442
{
28443+
"description": "If true, the destination must be an index alias.",
2842628444
"name": "require_alias",
2842728445
"required": false,
28446+
"serverDefault": false,
2842828447
"type": {
2842928448
"kind": "instance_of",
2843028449
"type": {
@@ -28434,8 +28453,10 @@
2843428453
}
2843528454
},
2843628455
{
28456+
"description": "Specify how many times should the operation be retried when a conflict occurs.",
2843728457
"name": "retry_on_conflict",
2843828458
"required": false,
28459+
"serverDefault": 0,
2843928460
"type": {
2844028461
"kind": "instance_of",
2844128462
"type": {
@@ -28445,6 +28466,7 @@
2844528466
}
2844628467
},
2844728468
{
28469+
"description": "Custom value used to route operations to a specific shard.",
2844828470
"name": "routing",
2844928471
"required": false,
2845028472
"type": {
@@ -28456,19 +28478,10 @@
2845628478
}
2845728479
},
2845828480
{
28459-
"name": "source_enabled",
28460-
"required": false,
28461-
"type": {
28462-
"kind": "instance_of",
28463-
"type": {
28464-
"name": "boolean",
28465-
"namespace": "internal"
28466-
}
28467-
}
28468-
},
28469-
{
28481+
"description": "Period to wait for dynamic mapping updates and active shards. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.",
2847028482
"name": "timeout",
2847128483
"required": false,
28484+
"serverDefault": "1m",
2847228485
"type": {
2847328486
"kind": "instance_of",
2847428487
"type": {
@@ -28478,8 +28491,10 @@
2847828491
}
2847928492
},
2848028493
{
28494+
"description": "The number of shard copies that must be active before proceeding with the operations. Set to 'all' or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard.",
2848128495
"name": "wait_for_active_shards",
2848228496
"required": false,
28497+
"serverDefault": "1",
2848328498
"type": {
2848428499
"kind": "instance_of",
2848528500
"type": {
@@ -28489,8 +28504,10 @@
2848928504
}
2849028505
},
2849128506
{
28507+
"description": "Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve.",
2849228508
"name": "_source",
2849328509
"required": false,
28510+
"serverDefault": "true",
2849428511
"type": {
2849528512
"items": [
2849628513
{
@@ -28512,6 +28529,7 @@
2851228529
}
2851328530
},
2851428531
{
28532+
"description": "Specify the source fields you want to exclude.",
2851528533
"name": "_source_excludes",
2851628534
"required": false,
2851728535
"type": {
@@ -28523,6 +28541,7 @@
2852328541
}
2852428542
},
2852528543
{
28544+
"description": "Specify the source fields you want to retrieve.",
2852628545
"name": "_source_includes",
2852728546
"required": false,
2852828547
"type": {

output/schema/validation-errors.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,12 +1819,6 @@
18191819
],
18201820
"response": []
18211821
},
1822-
"update": {
1823-
"request": [
1824-
"Endpoint has \"@stability: TODO"
1825-
],
1826-
"response": []
1827-
},
18281822
"update_by_query": {
18291823
"request": [
18301824
"Endpoint has \"@stability: TODO"

output/typescript/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,6 @@ export interface UpdateRequest<TDocument = unknown, TPartialDocument = unknown>
16651665
require_alias?: boolean
16661666
retry_on_conflict?: long
16671667
routing?: Routing
1668-
source_enabled?: boolean
16691668
timeout?: Time
16701669
wait_for_active_shards?: WaitForActiveShards
16711670
_source?: boolean | Fields

specification/_global/update/UpdateRequest.ts

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { Time } from '@_types/Time'
3636
/**
3737
* @rest_spec_name update
3838
* @since 0.0.0
39-
* @stability TODO
39+
* @stability stable
4040
*/
4141
export interface Request<TDocument, TPartialDocument> extends RequestBase {
4242
path_parts?: {
@@ -45,29 +45,106 @@ export interface Request<TDocument, TPartialDocument> extends RequestBase {
4545
type?: Type
4646
}
4747
query_parameters?: {
48+
/**
49+
* Only perform the operation if the document has this primary term.
50+
*/
4851
if_primary_term?: long
52+
/**
53+
* Only perform the operation if the document has this sequence number.
54+
*/
4955
if_seq_no?: SequenceNumber
56+
/**
57+
* The script language.
58+
* @server_default painless
59+
*/
5060
lang?: string
61+
/**
62+
* If 'true', Elasticsearch refreshes the affected shards to make this operation
63+
* visible to search, if 'wait_for' then wait for a refresh to make this operation
64+
* visible to search, if 'false' do nothing with refreshes.
65+
* @server_default false
66+
*/
5167
refresh?: Refresh
68+
/**
69+
* If true, the destination must be an index alias.
70+
* @server_default false
71+
*/
5272
require_alias?: boolean
73+
/**
74+
* Specify how many times should the operation be retried when a conflict occurs.
75+
* @server_default 0
76+
*/
5377
retry_on_conflict?: long
78+
/**
79+
* Custom value used to route operations to a specific shard.
80+
*/
5481
routing?: Routing
55-
source_enabled?: boolean
82+
/**
83+
* Period to wait for dynamic mapping updates and active shards.
84+
* This guarantees Elasticsearch waits for at least the timeout before failing.
85+
* The actual wait time could be longer, particularly when multiple waits occur.
86+
* @server_default 1m
87+
*/
5688
timeout?: Time
89+
/**
90+
* The number of shard copies that must be active before proceeding with the operations.
91+
* Set to 'all' or any positive integer up to the total number of shards in the index
92+
* (number_of_replicas+1). Defaults to 1 meaning the primary shard.
93+
* @server_default 1
94+
*/
5795
wait_for_active_shards?: WaitForActiveShards
96+
/**
97+
* Set to false to disable source retrieval. You can also specify a comma-separated
98+
* list of the fields you want to retrieve.
99+
* @server_default true
100+
*/
58101
_source?: boolean | Fields
102+
/**
103+
* Specify the source fields you want to exclude.
104+
*/
59105
_source_excludes?: Fields
106+
/**
107+
* Specify the source fields you want to retrieve.
108+
*/
60109
_source_includes?: Fields
61110
}
62111
body?: {
112+
/**
113+
* Set to false to disable setting 'result' in the response
114+
* to 'noop' if no change to the document occurred.
115+
* @server_default true
116+
*/
63117
detect_noop?: boolean
64-
/** @prop_serializer SourceFormatter`1 */
118+
/**
119+
* A partial update to an existing document.
120+
* @prop_serializer SourceFormatter`1
121+
*/
65122
doc?: TPartialDocument
123+
/**
124+
* Set to true to use the contents of 'doc' as the value of 'upsert'
125+
* @server_default false
126+
*/
66127
doc_as_upsert?: boolean
128+
/**
129+
* Script to execute to update the document.
130+
*/
67131
script?: Script
132+
/**
133+
* Set to true to execute the script whether or not the document exists.
134+
* @server_default false
135+
*/
68136
scripted_upsert?: boolean
137+
/**
138+
* Set to false to disable source retrieval. You can also specify a comma-separated
139+
* list of the fields you want to retrieve.
140+
* @server_default true
141+
*/
69142
_source?: boolean | SourceFilter
70-
/** @prop_serializer SourceFormatter`1 */
143+
/**
144+
* If the document does not already exist, the contents of 'upsert' are inserted as a
145+
* new document. If the document exists, the 'script' is executed.
146+
* @prop_serializer SourceFormatter`1
147+
*/
71148
upsert?: TDocument
72149
}
73150
}

0 commit comments

Comments
 (0)