0

I want to annotate some messages in MongoDB from a social network as spam. If I use in the query _id, it works, but not using regular expression.

this works for one record:

db.group_data.update({_id:"gid_91496835_topic_192"},{$set:{SPAM:true}})

this doesn't work for all, but seems to update one record:

db.group_data.update({"text":/.*yburlan.ru.*/},{$set:{SPAM:true}})

WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

How can I update/set to all records found by regexp?

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
Valentin H
  • 7,240
  • 12
  • 61
  • 111

1 Answers1

3

You should add the multi option :

db.group_data.update({"text":/.*yburlan.ru.*/}, {$set:{SPAM:true}}, {multi: true})
Till
  • 4,183
  • 3
  • 16
  • 18