Skip to content

Instantly share code, notes, and snippets.

@yrezgui
Created June 3, 2014 21:27
Show Gist options
  • Select an option

  • Save yrezgui/9d68099c943128157296 to your computer and use it in GitHub Desktop.

Select an option

Save yrezgui/9d68099c943128157296 to your computer and use it in GitHub Desktop.
db.jobs.aggregate(
{ $match : {
salary_min : {
$gt : 1000,
$lt : 200000
}
}},
{ $project : {
title : 1,
salary_min : 1 ,
salary_max : 1,
tags: 1
}},
{ $unwind : "$tags" },
{ $project : {
title : 1,
salary_min : 1 ,
salary_max : 1,
skill: "$tags.display_name",
skillType: "$tags.tag_type"
}},
{ $match : {
skillType : "SkillTag"
}},
{ $group: {
_id : '$skill',
salary_min : { $avg : "$salary_min" },
salary_max : { $avg : "$salary_max" },
count : { $sum : 1 }
}},
{ $sort: {
count: -1,
salary_min: -1,
salary_max: -1
}}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment