mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Specifying collations on queries

Open david-alm opened this issue 7 years ago • 2 comments

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.

david-alm avatar Mar 21 '19 14:03 david-alm

Let me take this one.

erdenezul avatar Mar 21 '19 16:03 erdenezul

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.

nsuthar0914 avatar Mar 22 '19 05:03 nsuthar0914