Hello there,
using mongo since approx. 2 months and so far I’m quite happy, however we stumbled upon our first real problem.
One of our main use cases is a query e.g. by name. By default, the server should search case insensitively and with startsWith, so I’m doing sg. like this:
{"name.family" : /^christiansen/i}
While this delivers the correct results, it is very inefficient. This is stated in the documentation and I can validate this by looking at the explain-stats (it uses the index but scans ALL documents).
An index with a collation strength of 1 or 2 does not help my case, because then I still loose the startsWith capability.
Normalizing data on the way in is not really an option, unfortunately.
I’m quite baffled this does not really work, I think i must be missing something. That is something that is very easy to do in most common sql environments by using a simple LIKE qiery along with a functional index (toLowerCase or sg. similar).
Thank you!