Thanks a lot for the reply.
This is my scenario:
Example: Im inserting Doc that has,
ID = 123, person_name: “mike.”
After inserting that Doc ID, I will need to do upsert to the same doc this time with
ID = 123, Person_name: “mike”, Last_name: “stuart”
So my final doc need to look like:
ID= 123, person_name:”mike”, Last_name: ’’Stuart’’.
This is my code now
me.client.exists({
index: index,
type: type,
id: id
}, function(err, exists) {
if (err) {
cb(err)
} else {
if (exists === true) {
out('exists. doing update.');
// update existing document
me.client.update({
index: index,
type: type,
id: id,
body: {
doc: body
}
}, function(err, resp) {
if (err) {
cb(err);
} else {
cb(null, resp);
}
});
} else {
out('adding new document');
// add new document
me.client.create({
index: index,
type: type,
id: id,
body: body
}, function(err, resp) {
if (err) {
cb(err);
} else {
cb(null, resp);
}
});
}
Using this, Im able to get the correct results, but, I have a lot of "version conflict, document already exists" errors.
If I replace Update and Create with Index. then I dont have any errors, but Im saving im not doing an upsert.
what I receive in ES is
Doc ID: 123, person_name: "Mike"
Doc ID:124, Last_name: "Stuart".
it looks like its creating a new ID for each doc.
Thanks a lot in advance for your answer