From 53d986d7c2febc564be3c70a862ea5b5463e55e5 Mon Sep 17 00:00:00 2001 From: Nuhman Pk <62880706+nuhmanpk@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:56:40 +0530 Subject: [PATCH] Add update example for javascript client (#6243) * Add update example for javascript client Signed-off-by: Nuhman Pk <62880706+nuhmanpk@users.noreply.github.com> * Update _clients/javascript/index.md Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Nuhman Pk <62880706+nuhmanpk@users.noreply.github.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --- _clients/javascript/index.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/_clients/javascript/index.md b/_clients/javascript/index.md index f8bf9a96..e2bcc2b3 100644 --- a/_clients/javascript/index.md +++ b/_clients/javascript/index.md @@ -327,6 +327,27 @@ var response = await client.search({ ``` {% include copy.html %} +## Updating a document + +You can update a document using the client's `update` method: + +```javascript +var response = await client.update({ + index: index_name, + id: id, + body: { + doc: { + // Specify the fields and their updated values here + field1: "new_value1", + field2: "new_value2", + // Add more fields as needed + } + } +}); +``` + +{% include copy.html %} + ## Deleting a document You can delete a document using the client's `delete` method: @@ -481,4 +502,4 @@ var client = new Client({ }, }); ``` -{% include copy.html %} \ No newline at end of file +{% include copy.html %}