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>
This commit is contained in:
Nuhman Pk 2024-02-19 19:56:40 +05:30 committed by GitHub
parent 53f4683b41
commit 53d986d7c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 1 deletions

View File

@ -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 %}
{% include copy.html %}