[SERVER-13505] Query parser should reject $text predicate in $elemMatch Created: 07/Apr/14  Updated: 10/Dec/14  Resolved: 08/Apr/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.0-rc3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

The query parser should disallow use of $text inside $elemMatch. There is no functionality to match a $text predicate against a subdocument; $text predicates apply to the root of a document only.

Users receive the following cryptic error message when running an $elemMatch query that contains $text:

> db.foo.find({a:{$elemMatch:{b:1,$text:{$search:"hello"}}}})
error: {
	"$err" : "Unable to execute query: error processing query: ns=test.foo limit=0 skip=0\nTree: a $elemMatch (obj)\n    $and\n        b == 1.0\n        TEXT : query=hello, language=, 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" : 17007
}



 Comments   
Comment by Eliot Horowitz (Inactive) [ 08/Apr/14 ]

Not a syntax issue, a semantic issue.
Where the error is handled is ok, just could use clearer message

Generated at Thu Feb 08 03:31:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.