KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to Or some conditions in MongoDB (using the Java driver). This is what I'm doing : Pattern regex = Pattern.compile("title"); DBCollection coll = MongoDBUtil.getDB().getCollection("post_details"); BasicDBObject query = new BasicDBObject(); query.put("category_title", "myCategory"); query.append("post_title", regex); query.append("post_description", regex); DBCursor cur = coll.find(query); while(cur.hasNext()) { System.out.println(cur.next().get("post_id")); } I'd like to use the $or operand on these conditions, but I guess the default is "and" and I don't know how to change it. In the above code if one of the conditions returns null , the result will be null too.
Tags (comma-separated)
Save Edits
Cancel