Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Created May 16, 2014 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tugberkugurlu/f66898909185f9b9b268 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/f66898909185f9b9b268 to your computer and use it in GitHub Desktop.
MongoDB $unwind sample
db.contents.aggregate(
{ $match: { $and: [{ Type: "Api" }, { $text: { $search: "configuration" } }] } },
{ $sort: { score: { $meta: "textScore" } } },
{ $project: { _id: 1, Tags: 1 } },
{ $unwind: "$Tags" },
{ $group: { _id: "$Tags", count: { $sum : 1 } }}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment