Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

How to query MongoDB aggregate with collation option

$
0
0

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?


Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>