Getting a distinct aggregation of an array field across indexes

The code that fails on their website works on an actual MongoDB instance:

> db.posts.insert({title: "Hello", tags: ["one", "five"]});
> db.posts.insert({title: "World", tags: ["one", "three"]});
> db.posts.distinct("tags");
[ "one", "three", "five"]

Weird.

Leave a Comment