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. It's likely dead, dying, or wildly inaccurate.

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