Page 1 of 1

Using $text and $search for string searches

Posted: Sun Sep 14, 2014 3:27 pm
by Rena Hearn

I am trying to search a field called prod_desc.

I can successfully search the first word using the $regex.

I need to search the entire string.
for example "Bimbo Extra Soft White Bread" and I want to search Bread

I have tried return '{"prod_desc":{"$text":{"$search":"'+value+'","$options":"i"}}';
and return '{"prod_desc":{"$text":{"$search":"^'+value+'","$options":"i"}}';

Can someone help me find the right way? No tutorial links please...I came up with these strings after searching the mondodb tutorials. Thanks!!


Using $text and $search for string searches

Posted: Mon Sep 15, 2014 2:41 am
by Yurii Orishchuk

Hi Rena,

What is "$text" and "$search" ? Where did you get it from Appery.io documentaion?

Please take a look how to make reg exp search: http://devcenter.appery.io/documentat...

Solution for you:

pre

//To be sure you have correct value.
console.log("value = " + value);

var whereObject = {prod_desc: {"$regex": value, "$options":"gi" } };
return JSON.stringify(whereObject);

/pre

Regards.


Using $text and $search for string searches

Posted: Mon Sep 15, 2014 4:20 am
by Rena Hearn

THAT WORKS!! You are my hero..nearly. Look-up my other topics I posted out of desperation! LOL

Thank You!

ps http://devcenter.appery.io/documentat... this says to see the mongodb documentation for more info.