I have following code to search in mongo db using spring data mongodb ( version 1.2.3.RELEASE)
Criteria searchCriteria = Criteria.where("NAME").is("TestName")
.and("ID").is("TestID").not().and("Age").is("23");
I got following query ( without not operator )
Query: { "NAME" : "TestName" , "ID" : "TestID", "Age" : "23" }
I was expecting following query
Query: { "NAME" : "TestName" , "$not" : { "ID" : "TestID"}, "Age" : "23" }
What am i doing wrong ? Any help is greatly appreciated. Thanks
I used 'ne' instead.
Criteria searchCriteria = Criteria.where("NAME").is("TestName").and("ID").ne("TestID").and("Age").is("23");
Mongo db 'not' is a logical operator. http://docs.mongodb.org/manual/reference/operator/query/not/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With