Created
June 3, 2014 21:27
-
-
Save yrezgui/9d68099c943128157296 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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