I'm not sure exactly what the problem is without having your data and being able to run your query. However, there are lots of issues with this code:
- Why save this as a script and then call db.eval() rather than running your update directly?
- Why do you need to reindex?
- You do not need the $and operator in your query.
- You do not need separate calls to find and update; in fact, one call to update with the multiupdate flag set to true should suffice.
- The $in is unnecessary in {"$in": ["Notes"]}.
- Using {$regex: '.Green Red.'} could potentially be slow. The $regex operator cannot use an index in this case because an index can only be used to match a prefix. See the last paragraph here: http://docs.mongodb.org/manual/reference/operator/regex/.
If this is code generated by UMongo, I recommend moving away from UMongo and working with the officially supported mongo shell.
In order to fix your call to update, try running something like this in the mongo shell:
db.data.update(
{
"title": {$regex : '.*Green Red.*', $options : 's'},
"editor.key": {"$in": ["74014","45339"]},
"types" : "Notes"
},
{
$set: {
"editor.key": "05335",
"editor.value": "editor1",
"editor.email": "editor1@gmail.com"
}
},
false,
true
);