Reputation: 8932
I m using Spring Data with Mongodb and I m facing a problem. I cant execute my criteria query in my repository with this :
@Query("{'name':/.*?0.*/}")
public List<DirectoryEntity> findByName(String name);
What is the good way of make it work ? I need simple criteria, the name contains param.
What is the good way to request with this annotation ?
Upvotes: 2
Views: 310
Reputation: 103445
Try using the $regex
operator in your query expression:
@Query("{'name':{'$regex':?0,$options:'i'}}")
public List<DirectoryEntity> findByName(String name);
The i
option in the regex expression toggles case insensitivity, and allows all letters in the pattern to match upper and lower cases.
Upvotes: 1