diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 7811993a1b..f9e824a3f5 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -38461,7 +38461,7 @@ "$ref": "#/components/schemas/_global.search._types:SourceConfig" }, "upsert": { - "description": "If the document does not already exist, the contents of 'upsert' are inserted as a new document.\nIf the document exists, the 'script' is run.", + "description": "Upserts are powerful operations that enable you to perform both update and insert actions in a single request.\nIf the document does not already exist, the contents of 'upsert' are inserted as a new document.\nIf the document exists, the script is run.", "type": "object" } } diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 3bd4bc32a6..8b550123fc 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -19947,7 +19947,7 @@ "$ref": "#/components/schemas/_global.search._types:SourceConfig" }, "upsert": { - "description": "If the document does not already exist, the contents of 'upsert' are inserted as a new document.\nIf the document exists, the 'script' is run.", + "description": "Upserts are powerful operations that enable you to perform both update and insert actions in a single request.\nIf the document does not already exist, the contents of 'upsert' are inserted as a new document.\nIf the document exists, the script is run.", "type": "object" } } diff --git a/output/schema/schema.json b/output/schema/schema.json index f481125348..4f31a6617d 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -43234,7 +43234,7 @@ } }, { - "description": "If the document does not already exist, the contents of 'upsert' are inserted as a new document.\nIf the document exists, the 'script' is run.", + "description": "Upserts are powerful operations that enable you to perform both update and insert actions in a single request.\nIf the document does not already exist, the contents of 'upsert' are inserted as a new document.\nIf the document exists, the script is run.", "name": "upsert", "required": false, "type": { @@ -43451,7 +43451,7 @@ } } ], - "specLocation": "_global/update/UpdateRequest.ts#L38-L189" + "specLocation": "_global/update/UpdateRequest.ts#L38-L190" }, { "kind": "response", diff --git a/specification/_global/update/UpdateRequest.ts b/specification/_global/update/UpdateRequest.ts index d61706c18f..4f8f2ee555 100644 --- a/specification/_global/update/UpdateRequest.ts +++ b/specification/_global/update/UpdateRequest.ts @@ -180,8 +180,9 @@ export interface Request extends RequestBase { */ _source?: SourceConfig /** + * Upserts are powerful operations that enable you to perform both update and insert actions in a single request. * If the document does not already exist, the contents of 'upsert' are inserted as a new document. - * If the document exists, the 'script' is run. + * If the document exists, the script is run. * @prop_serializer SourceFormatter`1 */ upsert?: TDocument diff --git a/specification/_global/update/examples/request/UpdateRequestExample9.yaml b/specification/_global/update/examples/request/UpdateRequestExample9.yaml index bf2e4662d1..3e3ac679cb 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample9.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample9.yaml @@ -1,10 +1,8 @@ summary: Upsert # method_request: POST test/_update/1 description: > - Run `POST test/_update/1` to perfom an upsert. - If the document does not already exist, the contents of the upsert element are inserted as a new document. If the document exists, the script is run. + Run `POST test/_update/1` to perfom update and insert actions in a single request. + In this example, if the product with ID 1 exists, its price will be updated to 100. + If the product does not exist, a new document with ID 1 and a price of 50 will be inserted. # type: request -value: - "{\n \"script\": {\n \"source\": \"ctx._source.counter += params.count\"\ - ,\n \"lang\": \"painless\",\n \"params\": {\n \"count\": 4\n }\n \ - \ },\n \"upsert\": {\n \"counter\": 1\n }\n}" +value: { 'doc': { 'product_price': 100 }, 'upsert': { 'product_price': 50 } }