Page 1 of 1

Looking to use $text and $search

Posted: Sun Apr 03, 2016 5:22 pm
by Ellen Schlechter

I want to be able to search the comment column of my database. Usually there are a few words saved in the string.

I think that $text and $search will work, according to Mongo's docs. I just don't know how to put it together to make it work. I also do not want it to be case sensitive so I would also need $options, 'i' right?

How would I put the three of these together? Or is there a better way of doing it?


Looking to use $text and $search

Posted: Mon Apr 04, 2016 3:13 pm
by Serhii Kulibaba

Hello Ellen,

Appery.io doesn't support these parameters. Please use $regex for that: https://devcenter.appery.io/documenta...


Looking to use $text and $search

Posted: Mon Apr 04, 2016 3:39 pm
by Ellen Schlechter

So if I searched the word "little", it would find something that had "three little bunnies"? Do I need to use any $options or does $regex work in this way alone?


Looking to use $text and $search

Posted: Mon Apr 04, 2016 3:50 pm
by Ellen Schlechter

I tried $regex alone and I also tried it with $options "m" and "si" and in all of these examples, it would only match exact matches instead of ones that just contain the word.


Looking to use $text and $search

Posted: Mon Apr 04, 2016 4:36 pm
by Ellen Schlechter

{"comment": {"$regex": value, "$options":"gi" } }

This seemed to work perfectly.