问题
Remove in momgodb using java not giving proper result. Am i missing something? My database is as below.

My code for removeing records where index = "7"
is as,
BasicDBObject whereQuery = new BasicDBObject("nodes.index", new BasicDBObject("$eq", "7"));
node_info.remove(whereQuery);
It's returning all the records and deleting my complete database. What can be probably wrong.?
回答1:
Instead of remove try $pull method code as below
BasicDBObject match = new BasicDBObject("_id", object id here);
BasicDBObject update = new BasicDBObject("nodes", new BasicDBObject("index", 7)))
node_info.update(match, new BasicDBObject("$pull", update);
来源:https://stackoverflow.com/questions/29600055/what-is-wrong-with-mongodb-remove-query-using-mongodb-java-for-sub-array-of-docu