Reputation: 1378
Hi guys I have an index which I want to update a part of using elastic search js
for example: I have this index:
{
"_index" : "users",
"_type" : "j_users",
"_id" : "CpmE0G0BteODhj-lZNPP",
"_score" : 1.0,
"_source" : {
"email" : "[email protected]",
"firstName" : "aa",
"lastName" : "aa",
"confirmed" : false,
}
and I wish to change only the "confirmed" field to true, how do I do that?
await client.update({
index: "users",
id: "CpmE0G0BteODhj-lZNPP",
body: {
confirmed: true
}
});
I tried this according to the documentation but I get an error, can anyone tell me whats wrong with my syntax?
Upvotes: 0
Views: 83
Reputation: 1285
Try this:
await client.update({
index: "users",
type : "j_users"
id: "CpmE0G0BteODhj-lZNPP",
body: {
doc: {
confirmed: true
}
}
});
you can also try to add
doc_as_upsert: true
Upvotes: 1