This is my sample code:
DBCollection coll = db.getCollection("testCollection");
BasicDBObject search = new BasicDBObject("$search", "mytextsearch");
BasicDBObject textSearch = new BasicDBObject("$text", search);
BasicDBObject projection = new BasicDBObject("score", new BasicDBObject("$meta", "textScore"));
myDoc = coll.findOne(textSearch, projection);
This should find the document, I call it myDoc, with the highest score for searching "mytextsearch".
Then, I want to remove this document from the collection, so I did:
coll.remove(myDoc);
However, this has no effect on the collection, and myDoc is never deleted. What am I doing wrong? I want to be able to delete myDoc after I have found it.