I have a collection that records comments from users. Something like the below:
{
_id:1
"statusReason" : {
"text" : {
"value" :"Hello there 😊"
}
}
}
I need to write a query that can identify any comments containing any emoji.
MongoDB version: 3.4.24
2
Answers
As MongoDB stores by default using UTF-8, you can simply search with regex of the unicode range of the emojis that you are interested of. You can check for the latest unicode range for emojis here
Here is the Mongo playground for your reference.
Using that example:
And that query:
I returned the message you requested:
Here you can see the query in Mongo playground: [Link to Mongo Playground]
1
Useful documentation: