[SERVER-42235] Err: $not cannot have a regex, db -v=4.0.10 Created: 15/Jul/19  Updated: 27/Oct/23  Resolved: 29/Jul/19

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

Type: Bug Priority: Major - P3
Reporter: Yeshu Kochher Assignee: Kelsey Schubert
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac


Attachments: PNG File Screenshot 2019-07-15 at 5.33.17 AM.png    
Participants:

 Description   

Hello MongoDB Community

I am having trouble with $not operator. Getting error that "$not cannot have a regex". I looked into official documentation but it's says it shall work from version 4.0.7. So, I tried updating my mongodb and installed latest stable version 4.0.10. But still getting same error. I am attaching my error screenshot. Please let me know if I am doing anything wrong.

 

Many thanks in advance.



 Comments   
Comment by Yeshu Kochher [ 17/Jul/19 ]

Hi Kelsey,

Thank you for replying. Please accept my apologies, because I did update the mongoDb version, but somehow brew service not updated with new version. Once I looked at by ```db.version()``` I found the issue. So, I restart the service with newer version and query is running without any error.

Thank you so much for your time.

Comment by Kelsey Schubert [ 16/Jul/19 ]

Hi yeshu@outlook.in,

Would you please confirm the version of the mongod that is running by executing db.version() from the shell? I'm not able to reproduce this issue:

> db.categories.find({name: {'$not':{'$regex': /e/ }}})
Error: error: {
	"ok" : 0,
	"errmsg" : "$not cannot have a regex",
	"code" : 2,
	"codeName" : "BadValue"
}
> db.version()
4.0.6

> db.categories.find({name: {'$not':{'$regex': /e/ }}})
> db.version()
4.0.10

Thanks,
Kelsey

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