Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Query builder support for $text operator in MongoDB 2.6 #162

Closed
jmikola opened this issue Mar 28, 2014 · 3 comments
Closed

Query builder support for $text operator in MongoDB 2.6 #162

jmikola opened this issue Mar 28, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@jmikola
Copy link
Member

jmikola commented Mar 28, 2014

http://docs.mongodb.org/master/reference/operator/query/text/#op._S_text

Prior to 2.6, text search is achieved via the text database command. We will not add special support for that.

@kriswallsmith
Copy link
Contributor

👍

Do you have a workaround in the meantime?

@kriswallsmith
Copy link
Contributor

Answering my own question…

$expr = $builder->expr()->operator('$text', array(
    '$search'   => $query,
    '$language' => 'en', // or one of those other languages
));

$builder->field(null)->equals($expr->getQuery());

If you get the following error, you are probably missing the ->field(null) part…

Can't canonicalize query: BadValue unknown operator: $text

@snc
Copy link

snc commented Aug 11, 2014

It looks like $builder->field(null)->... clears the previous added fields, so this should be the first one if you have more fields in your query.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants