Created
February 15, 2018 20:40
-
-
Save Jamp/6f1f0ac59990d5ae7029cae2434b4675 to your computer and use it in GitHub Desktop.
Consultas optimizadas para los tweets en mongodb
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.tweets.aggregate( | |
{ | |
$project: { | |
y: { $year: "$created_at"}, | |
m: { $month: "$created_at"}, | |
d: { $dayOfMonth: "$created_at"}, | |
h: { $hour: "$created_at"}, | |
tweet: 1 | |
} | |
}, | |
{ | |
$group:{ | |
_id: { year: "$y", month:"$m", day:"$d", hour:"$h" }, | |
count: { $sum : 1 } | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment