Setup mongo to always use collation indexes

Hi guys,

We’re looking into doing better search on our collections that include a variety of accents (french, german, and english).

This can be done using Mongo’s collation feature:

Here’s an example from an old thread on these forums:

import { MongoInternals } from 'meteor/mongo';

const { db } = MongoInternals.defaultRemoteCollectionDriver().mongo;
db.createCollection('myCollection', {
  collation: {
    locale: 'fr',
    strength: 1,
  },
});

Is there now a way to set this up using new Mongo.Collection? I’d like to avoid copy pasting that entire function to get all the rest of the functionality which we’re using.

And once that’s done, you need to plug the collation in every find on those collections. I’m again not sure if there is a way to make all finds to use it without a gigantic refactor everywhere, maybe there is some kind of meteorhacks hook that could help you do this from a few lines of code?

Override the mongo functions. Using something similar to get an explain plan for all queries