Created
November 25, 2015 22:12
-
-
Save alexshyba/fac845dc5b6ca61730bc to your computer and use it in GitHub Desktop.
Mongo: using aggregate to access page event meta data within XDB
This file contains 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.Interactions.aggregate([ | |
{ "$match": { "StartDateTime": { $gte: ISODate("2015-11-01T00:00:00.000Z"), | |
$lt: ISODate("2015-11-01T03:00:00.000Z")}}}, | |
{ $project : { Pages : "$Pages" } }, | |
// Un-wind the array's to access filtering | |
{ "$unwind": "$Pages" }, | |
{ "$unwind": "$Pages.PageEvents" }, | |
// Group results to obtain the matched count per key | |
{ "$group": { | |
"_id": "$Pages.PageEvents.Name", | |
"count": { "$addToSet": "$Pages.PageEvents.Text" } | |
} | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment