failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?

1,153 views
Skip to first unread message

antonio altamura

unread,
Mar 16, 2016, 9:22:13 PM3/16/16
to mongodb-user
Hi, I have a root schema and 4 inherited schemas.
The purpose is to index all the string fields of each inherited schema independently.
I tried (based on stackoverflow) this on root schema
{ kind: 1, "$**": "text" }

where 'kind' is the discriminatorKey.
I get the error 
{
"name": "MongoError",
"message": "error processing query: ns=myDB.caseNotesTree: TEXT : query=title, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL\nSort: {}\nProj: {}\n planner returned error: failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)",
"waitedMS": 0,
"ok": 0,
"errmsg": "error processing query: ns=myDB.caseNotesTree: TEXT : query=title, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL\nSort: {}\nProj: {}\n planner returned error: failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)",
"code": 2
}


Wan Bachtiar

unread,
Mar 31, 2016, 9:01:19 PM3/31/16
to mongodb-user

where ‘kind’ is the discriminatorKey. I get the error

Hi Antonio,

In your case, since kind proceeded the text index keys in the compound text index, you would have to run the query including kind field. For example:

db.collection.find({kind: 42, $text: {$search:"foo"}})

See also Wildcard Text Indexes.

Worth noting that starting in MongoDB v3.2, there is a new text index: text index version 3. See Text Indexes for the new key features.

If you have further questions please also include the following information:

  • MongoDB version.
  • Query performed.

Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages