Guest User

Untitled

a guest
Aug 6th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. SpringMongo Case insensitive search regex
  2. Query query = new Query( Criteria.where(propName).regex(value.toString(), "i"));
  3.  
  4. > db.foo.insert({name: "Bill"});
  5. > db.foo.insert({name: "Bill status"});
  6. > db.foo.insert({name: "another Bill"});
  7. > db.foo.find()
  8. { "_id" : ObjectId("5018e182a499db774b92bf25"), "name" : "Bill" }
  9. { "_id" : ObjectId("5018e191a499db774b92bf26"), "name" : "Bill status" }
  10. { "_id" : ObjectId("5018e19ba499db774b92bf27"), "name" : "another Bill" }
  11. > db.foo.find({name: /bill/i})
  12. { "_id" : ObjectId("5018e182a499db774b92bf25"), "name" : "Bill" }
  13. { "_id" : ObjectId("5018e191a499db774b92bf26"), "name" : "Bill status" }
  14. { "_id" : ObjectId("5018e19ba499db774b92bf27"), "name" : "another Bill" }
  15. > db.foo.find({name: /^bill$/i})
  16. { "_id" : ObjectId("5018e182a499db774b92bf25"), "name" : "Bill" }
Advertisement
Add Comment
Please, Sign In to add comment