Makoto
Makoto

Reputation: 775

equivalent of like in mongodb spring

I would like to find the equivalent of LIKE in mongodb spring

Here is the request with the exact match

query.addCriteria(Criteria.where(field).is("myfield"))

I would like something like:

query.addCriteria(Criteria.where(field).LIKE("myfield"))

Upvotes: 0

Views: 298

Answers (1)

Petr Mensik
Petr Mensik

Reputation: 27526

You can try making it regex, this results in the same ouput like in the case of LIKE.

Criteria.where(field).regex("myfield", "i");

Note that i stands for case-insensitive.

Upvotes: 1

Related Questions