Domanda

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?

È stato utile?

Soluzione

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')));
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top