[SERVER-12629] Allow $meta projections inside subdocuments Created: 05/Feb/14  Updated: 06/Dec/22  Resolved: 10/Nov/20

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

Type: Improvement Priority: Major - P3
Reporter: J Rassi Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Participants:

 Description   

> db.foo.find({$text:{$search:'hello'}},{"a.b":{$meta:"textScore"}})
error: {
	"$err" : "Can't canonicalize query: BadValue field for $meta cannot be nested",
	"code" : 17287
}



 Comments   
Comment by David Storch [ 10/Nov/20 ]

This limitation does not appear to exist on HEAD of the master branch:

MongoDB Enterprise > db.c.drop()
false
MongoDB Enterprise > db.c.insert({a: "foo"})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise > db.c.createIndex({a: "text"})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
MongoDB Enterprise > db.c.find({$text: {$search: "foo"}})
{ "_id" : ObjectId("5faad8454276776545b2214f"), "a" : "foo" }
MongoDB Enterprise > db.c.find({$text: {$search: "foo"}}, {"a.b": {$meta: "textScore"}})
{ "_id" : ObjectId("5faad8454276776545b2214f"), "a" : { "b" : 1.1 } }

I'm not sure exactly when this was changed, so I will just close this ticket as "Gone Away".

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