Shane A. Stillwell
Performing a 'like' match in MongoDB

Performing a 'like' match in MongoDB

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. The Times They Are A-Changin'

So looking through the Doctrine ODM docs on Query Building, I didn’t see anything that lent itself to a like query such as that is found in MySQL. There isn’t a like, option, but using Regular Expressions will work just fine for me.

$queryBuilder->field('title')->equals(new \MongoRegex('/keyword/i'));

That will perform a case-insensitive query for the term ‘keyword’ in the field ‘title

Resources http://groups.google.com/group/doctrine-user/browse_thread/thread/daadb4e3030c196c