Page 2 of 2

Text search problem

Posted: Tue Jan 14, 2014 4:01 am
by Igor

Hi,

Let's see if this help:
pre
code
{"fieldName":{"$regex":"wor","$options":"im"}}
/code
/pre

This link should be helpful: http://docs.mongodb.org/manual/refere...


Text search problem

Posted: Tue Jan 14, 2014 4:05 am
by bahar.wadia

Hello Igor,

This only works for the first word in the sentence. Meaning, in the example I described above it will not return any rows because 'world' is the second word.

Thanks


Text search problem

Posted: Tue Jan 14, 2014 11:03 am
by Maryna Brodina

Hello! Try pre{"fieldName": {"$regex": "\\bwor.*", "$options":"im"}}/pre


Text search problem

Posted: Tue Jan 14, 2014 1:01 pm
by bahar.wadia

That works great. I was missing the extra \ .

I am assuming that since you use Mongodb, which is compatible with PCRE, one can use any PCRE directives. Am I correct in my assumption?


Text search problem

Posted: Tue Jan 14, 2014 1:14 pm
by Maryna Brodina

Yes, you're right.


Text search problem

Posted: Tue Jan 14, 2014 1:17 pm
by bahar.wadia

Thank you and slight correction...

when passing a query parameter the correct format is:

{"fieldName": {"$regex": "\\\\bwor.*", "$options":"im"}}

Thanks


Text search problem

Posted: Wed Apr 15, 2015 9:12 pm
by Joe7349603

Thanks for sharing ended up using your solution...Works great! Cheers!


Text search problem

Posted: Thu Apr 16, 2015 9:43 pm
by Adam Garbinski

Glad it worked for you Joe! You welcome.