Pergunta

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?

Foi útil?

Solução

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')));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top