Question

i'm doing search with ZF2 Doctrine2 ODM and using MongoRegix but the problem is that i'm not able to search those terms which contains brackets like BS(Hons) is not searchable. my query is

$q->addOr($q->expr()->field($columns[$i]['field'])->equals(new \MongoRegex('/.*BS(Hons).*/i')));

any suggestion?

Était-ce utile?

La solution

Reserved characters can be used in MongoRegx in the way.

/.*BS/(Hons/).*/i

the Query will be like this

$q->addOr($q->expr()->field($field)->equals(new \MongoRegex('/.*BS/(Hons/).*/i')));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top