Page 1 of 2

Indexed Database Text search error

Posted: Mon Oct 26, 2015 9:40 pm
by Juan Pieterse

Hi.
On a QUERY service I use the following query string:
{ $text: { $search: "Coffee" } }
As per screenshot below. There are 2 indexed columns in the database.
Image
Can anyone help me with this one? Is my syntax wrong?


Indexed Database Text search error

Posted: Tue Oct 27, 2015 8:02 am
by Serhii Kulibaba

Hello Juan,

Please look at this documentation page: https://devcenter.appery.io/documenta...


Indexed Database Text search error

Posted: Tue Oct 27, 2015 8:20 am
by Juan Pieterse

Hi thanks. So, I assume indexed searches are out?
I can use a regex search, but I'll need a little help.

In my collection, I've got 2 columns, ColA and ColB (both are text columns)
I have 3 'keywords' e.g. "Coffee", "Tea" and "Ice".
I would like to do a query on the collection and have it return a result of all records where any (or both) of the columns contain any (or all) of the keywords.
Not sure what the regex query for this will look like.

Thanks :)


Indexed Database Text search error

Posted: Tue Oct 27, 2015 8:28 am
by Juan Pieterse

Ok, thanks.. In that case (no indexed search) please see my follow-up question below. :)


Indexed Database Text search error

Posted: Tue Oct 27, 2015 11:53 am
by Serhii Kulibaba

In this way you have to use "$or" parameter: https://devcenter.appery.io/documenta...


Indexed Database Text search error

Posted: Tue Oct 27, 2015 12:48 pm
by Juan Pieterse

Ah thanks. What is the regex syntax to check for a string containing a substring.
StringA = "Coffee"
StringB = "The Coffee shop"

so basically a regex that will return 'true' when searching for the string "Coffee" in stringB.

Cheers


Indexed Database Text search error

Posted: Wed Oct 28, 2015 11:07 am
by Serhii Kulibaba

Please use simple strings for that:
{"$regex": "Coffee"}
and
{"$regex": "The Coffee shop"}


Indexed Database Text search error

Posted: Wed Jun 01, 2016 9:46 am
by EJLD

Hi There, it's about indexing a field in collection.
after creating the new collection
I inserted 2 columns. one of them I wanted it indexed, therefore I went to the "Index Manager" tab.
so far all fine.

then, comes my question: in my serverCode, shall I call that index again ?

I tried using

db.collection.ensureIndex({'columnName':1});

but got error msg cannot find undefined ... which means it does find the columnName ...

I m not to use this code if not necessary since the index is declared already.
what to do to make it effective ?

thks in advance,
Eric


Indexed Database Text search error

Posted: Wed Jun 01, 2016 3:06 pm
by Serhii Kulibaba

Hello,

Please clarify, where did you found that code? What are you trying to do?


Indexed Database Text search error

Posted: Thu Jun 02, 2016 5:44 am
by EJLD

Hi Sergiy, I got that one there https://docs.mongodb.com/manual/refer...

maybe not necessary, since the indexed field does exist in the "manage index" tab ?

tell me,
best,
Eric