I am updating the existing document in Elasticsearch by below update query.
const result = await client.update({
index,
id,
body: {
script: {
lang: "painless",
source: "ctx._source = params.customerDetailsObj",
params: {
customerDetailsObj: item
}
}
}
});
where item has below structure -
customerDetails: {
details,
metadata
}
and client is elasticsearch
client
id and index are correct values where id belongs to already existing id in Elasticsearch
const { Client } = require("@elastic/elasticsearch");
and already saved document structure is below -
{
"_index" : "customerdetailsreport",
"_type" : "_doc",
"_id" : "cu-qo4MBxhUIUIg_lZUJ",
"_score" : 12.078913,
"_source" : {
"customerDetails" : {
"details" : {
"id" : "1234567",
"name" : "Atul Joshi",
},
"metadata" : {
"id" : "1234567"
}
}
}
}
The issue I am facing is , after update operation , existing item is not updated but a new entry is created
So , In Elasticsearch I find two documents with different _id meaning two different entries are created
Can anybody please help what I am missing here ?