[SERVER-36707] No array filter found for identifier <identifier> in path <path> Created: 16/Aug/18  Updated: 27/Oct/23  Resolved: 17/Aug/18

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

Type: Bug Priority: Major - P3
Reporter: Dominic Kerchner Assignee: Nick Brewer
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

 

db.students.insert( { "_id" : 1, "grades" : [ { "grade" : 80, "mean" : 75, "std" : 6 }, { "grade" : 85, "mean" : 90, "std" : 4 }, { "grade" : 85, "mean" : 85, "std" : 6 } ] }) 
db.students.insert( { "_id" : 2, "grades" : [ { "grade" : 90, "mean" : 75, "std" : 6 }, { "grade" : 87, "mean" : 90, "std" : 3 }, { "grade" : 85, "mean" : 85, "std" : 4 } ] })

 

db.foo.update( { }, { $set: { "grades.$[elem].mean" : 100 } }, { multi: true, arrayFilters: [ { "elem.grade": { $gte: 85 } } ] } )

result: 

No array filter found for identifier 'elem' in path 'grades.$[elem].mean'

 

Participants:

 Description   

I am trying to create a query that updates arrayed subdocuments, but I keep getting an error:

"No array filter found for identifier '<identifier>' in path '<path>'"

 

It is reproducible using the examples from the documentation. 

db.version() shows 3.6.6



 Comments   
Comment by Nick Brewer [ 17/Aug/18 ]

dkerchner Glad to hear it's working.

-Nick

Comment by Dominic Kerchner [ 17/Aug/18 ]

Okay, I feel dumb now. I tried it from a shell version that was the same and it works properly. Sorry. 

Comment by Dominic Kerchner [ 16/Aug/18 ]

That was a typo on my part as I was trying different things out. I will check the versions when I get in in the morning. 

Comment by Nick Brewer [ 16/Aug/18 ]

dkerchner I can't reproduce this - I've used the exact steps you've provided, and I received:

db.students.update( { }, { $set: { "grades.$[elem].mean" : 100 } }, { multi: true, arrayFilters: [ { "elem.grade": { $gte: 85 } } ] } )
WriteResult({ "nMatched" : 2, "nUpserted" : 0, "nModified" : 2 })

Notably, I did change db.foo.update to db.students.update since that's the collection that the previous commands were using - however specifying the wrong collection shouldn't result in the error you're seeing.

Are you using the 3.6 shell? You should see a WARNING: shell and server versions do not match if the shell and server version don't match.

-Nick

Generated at Thu Feb 08 04:43:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.