Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SpringMongo Case insensitive search regex
- Query query = new Query( Criteria.where(propName).regex(value.toString(), "i"));
- > db.foo.insert({name: "Bill"});
- > db.foo.insert({name: "Bill status"});
- > db.foo.insert({name: "another Bill"});
- > db.foo.find()
- { "_id" : ObjectId("5018e182a499db774b92bf25"), "name" : "Bill" }
- { "_id" : ObjectId("5018e191a499db774b92bf26"), "name" : "Bill status" }
- { "_id" : ObjectId("5018e19ba499db774b92bf27"), "name" : "another Bill" }
- > db.foo.find({name: /bill/i})
- { "_id" : ObjectId("5018e182a499db774b92bf25"), "name" : "Bill" }
- { "_id" : ObjectId("5018e191a499db774b92bf26"), "name" : "Bill status" }
- { "_id" : ObjectId("5018e19ba499db774b92bf27"), "name" : "another Bill" }
- > db.foo.find({name: /^bill$/i})
- { "_id" : ObjectId("5018e182a499db774b92bf25"), "name" : "Bill" }
Advertisement
Add Comment
Please, Sign In to add comment