quma
quma

Reputation: 5733

Spring data - MongoDB - case insensitive

I use this query and I will make the search case insensitive:

@Query("{ $or: [ { 'name' : { $regex: ?0 }, 'number' : { $regex: ?1 } } ] }")

Is there a possibility to do this?

Upvotes: 0

Views: 2394

Answers (1)

Pubudu Jayawardana
Pubudu Jayawardana

Reputation: 2365

You can use options to force case insensitivity: $options: 'i'

@Query("{ $or: [ { 'name' : { $regex: ?0 }, 'number' : { $regex: ?1 } } ], { $options: 'i' } }")

Upvotes: 2

Related Questions