Mongoengine: Specifying collations on queries

Created on 21 Mar 2019  路  2Comments  路  Source: MongoEngine/mongoengine

Feature request
Although defining collations on indexes is doable through meta, it's not currently possible to define a collation on a query as specified by the PyMongo API

The current use-case is that of a case-insensitive indexed query - which could be done using regexes, but that would incur the cost of a scan as opposed to using the actual index.

feature

Most helpful comment

Let me take this one.

All 2 comments

Let me take this one.

Was trying to do the same almost at the same time as when this feature request was made :D.
My workaround was this:

@property
    def _cursor(self):
        if self._cursor_obj:
            return self._cursor_obj
        self._cursor_obj = QuerySet._cursor.fget(self)
        self._cursor_obj.collation(Collation(locale="en", strength=CollationStrength.SECONDARY))
        return self._cursor_obj

Looking forward to the actual feature implementation.

Was this page helpful?
0 / 5 - 0 ratings