I created a "brands" collection and then added an index collation: { locale: "en", strength: 2}
on the "title" field. But when I try to query it using this collation it doesn't work as expected:
const query = brand => mongodb.db("my-db").collection("brands")
.aggregate([
{ $match: { title: brand } },
{ $project: { _id: 0, total: 1, categories: { $slice: [ "$categories", 5 ] }, tags: { $slice: [ "$tags", 5 ] } } }
], { collation: { locale: 'en', strength: 2 } })
.asArray();
so calling brand('Test')
gives results but brand('test')
gives an empty list.
When I try the same query using Atlas Aggregation Builder both queries give the same (non-empty) result. Any ideas?
{ collation: { locale: 'en', strength: 2 } }
, (and this is as in the question post). If you are using Mongoose ODM, collation is specified asModel.aggregate(...).collation( { ... } )
. – Breed