'Searching using japanese string in documentdb

I'm trying to search in a collection containing firstname and lastname in japanese characters. Somehow there is no result returned even when there is data in the collection.

Here is the code I have right now which does not yield any result.

rgx = re.compile(f".*ひらがな.*", re.IGNORECASE)

query = [
    {
        "$match": {
            "$or": {
                {"firstname": rgx},
                {"lastname": rgx}
            }
        }
    }
]

members = db.users.aggregate(query)

Any idea on this one?

DocumentDB implements the MongoDB v3.6 API. But somehow according to the docs, cursor.collation() is still not supported.



Solution 1:[1]

The aggregation query doesn't look right to me, it should be:

[
    {
        "$match": {
            "$or": [
                {"firstname": { $regex: rgx }},
                {"lastname": { $regex: rgx }}
            ]
        }
    }
]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mihai A