Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Indexed Database Text search error

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?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Indexed Database Text search error

Hello Juan,

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

Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Indexed Database Text search error

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 :)

Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Indexed Database Text search error

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Indexed Database Text search error

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

Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Indexed Database Text search error

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Indexed Database Text search error

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

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Indexed Database Text search error

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Indexed Database Text search error

Hello,

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

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Indexed Database Text search error

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

Return to “Issues”