$ne in momgodb using java not giving proper result. Am i missing something?
My database is as below.
Which contains value where mac_address = "-".
My code for retrieving records where mac_address != "-"
is as,
BasicDBObject whereQuery = new BasicDBObject("mac_address", new BasicDBObject("$ne", "-"));
DBCursor cursor = node_info.find(whereQuery);
It's returning all the records. What can be probably wrong.?
Update i converted your suggested query as follow. what's wrong in this?
BasicDBObject unwind= new BasicDBObject("$unwind","$nodes");
BasicDBObject mac = new BasicDBObject("mac_address", "$nodes.mac_address");
BasicDBObject projection= new BasicDBObject("$project",mac);
BasicDBObject match = new BasicDBObject("$match", new BasicDBObject("mac_address",notEqual));
node_info.aggregate(unwind, projection, match);
Sorry i am not much familiar with mongodb query.