I am trying to execute a $ ne query in mongodb using a regex, but it does not seem to work. the $ ne operator (not equal) works fine when I don't use a regex.
BasicDBObject q = new BasicDBObject() q.put(field, ["\$ne": value])
works fine above, the result set does not contain documents that have this value for this field.
but I need it to be case insensitive. so i did it
q.put(field, ["\$ne": Pattern.compile(value, Pattern.CASE_INSENSITIVE)])
but it does not work.
so I thought, let me go to the command line and see if I can do this manually. so i did this:
db.Order.find({"bill.recipient.name": {$ne: /diep/i}},{"bill.recipient.name":1})
and it still does not work!
any ideas?
source share