PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Saturday the 6th of September, 2014

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[04:51:21] <mianos> simple question, in an aggregation does anyone know the syntax to get the _id from the initial match with the $group rows
[04:59:51] <sellout> mianos: Project the _id elsewhere prior to the group then use $first on that field when grouping?
[05:01:11] <mianos> hmm, $first may the trick thanks
[05:01:36] <mianos> I've got it projected: [{'$match': {'_id': ObjectId(activity.raw_activity)}}, {'$project': {'dpoint': '$events.records'}}, {'$unwind': '$dpoint'}, {'$unwind': '$dpoint'}, {'$project': { 'actid': '$_id', 'timestamp': '$dpoint.timestamp', 'minutes': {'$minute': '$dpoint.timestamp'}, 'hours': {'$hour': '$dpoint.timestamp'}, 'speed': '$dpoint.speed', '_id': 0}}, {'$group': { '_id': { 'hour': '$hours', 'min': '$minutes'}, 'avgspeed': {'$avg': '$
[05:02:36] <mianos> raw activity is two lists deep btw. That query works fine but I want to get the original match id and push to a list to save the aggregated list to a collection
[05:04:25] <sellout> mianos: $first is going to throw away _ids, though – if you want them all, then $push, or maybe sort them in some way prior to the $group to get the _id you want into $first position.
[05:07:07] <mianos> I might have to load it and store it in py I think. Too much for my mongo skills yet.
[05:14:11] <mianos> on this page http://docs.mongodb.org/manual/reference/operator/aggregation/push/#grp._S_push
[05:14:34] <mianos> it says it uses  field, the following operation uses the$addToSet accumulator
[05:14:45] <mianos> I can't see the acculator
[05:14:48] <mianos> accumulator
[05:17:00] <sellout> That seems to be a typo – it uses $push – and $push is the right thing there, because you don’t want to collapse two entries just because they sold the same quantity of the same item.
[05:18:08] <sellout> … especially since it’s on the page about $push
[05:18:34] <sellout> Here it is in the right context: http://docs.mongodb.org/manual/reference/operator/aggregation/addToSet/#example
[05:21:05] <poolside> hello! anyone have any experince with objectrocket? i’m having the n00biest issue connecting to my instance via node.js and the mongodb npm.. trying to follow this directions (http://docs.objectrocket.com/native_drivers.html) but am a bit confused as to where the dbconnctstring goes
[05:22:42] <mianos> can I push the $_id
[05:24:39] <sellout> mianos: Well, the _id is what you group on, but if you project it to actid like you do above, you can $push that, then you’ll have an array of all the ids that are in that group.
[06:02:08] <mianos> still trying, maybe if I run the data into another stage I can pivot it
[06:02:13] <mianos> now I have {u'_id': {u'hour': 19, u'min': 49}, u'actid': ObjectId('54015a3738bc1808dc45b7fb'), u'avgspeed': 24.20298677683631}]}
[06:02:19] <mianos> getting there
[06:03:00] <mianos> all I need to do is aggregate into a list with push on the common ObjectId for all times and speeds
[06:08:11] <mianos> ok that's it, thanks for your help anyway
[06:08:51] <mianos> i needed to pivot with another group stage
[06:09:02] <mianos> for anyone that cares:
[06:09:03] <mianos> {'$group': { '_id': { 'hour': '$hours', 'min': '$minutes'}, 'avgspeed': { '$avg': '$speed'}, 'actid': {'$first': '$actid'}}},
[06:09:03] <mianos> {'$group': { '_id': {'activity_id': '$actid'}, 'dpoints': {'$push': {'time': '$_id', 'spd': '$avgspeed'}}}}
[06:10:45] <mianos> so, first I aggregate the average speed and collection the activity id, I don't think I need '$first'
[06:11:55] <mianos> but it does not work otherwise because it wants an expression in the object
[06:20:47] <zamabe> I want to watch queries come in live. Can I do that?
[07:38:12] <mianos> can I create a native datetime from split parts in an aggregation pipeline?
[20:47:39] <theekgb> hello all
[20:50:11] <theekgb> wondering if anyone can help with how to remove a db from a secondary server
[21:33:57] <unholycrab> how does mongodb distribute query load across a non-sharded replica set?
[21:34:40] <unholycrab> does one member process the entire query?
[21:34:48] <unholycrab> and the queries just round-robin
[21:35:04] <unholycrab> or is a single query distributed among members
[22:56:42] <joannac> unholycrab: ?
[22:57:09] <joannac> whatever the read preference is
[23:52:43] <x00x90> can i have a TL;DR on how to install mongodb on linux ?
[23:53:35] <joannac> which linux?
[23:53:59] <x00x90> arch
[23:54:44] <joannac> http://docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/
[23:55:02] <x00x90> thanks
[23:56:47] <ag4ve> how do i query a db from a shell?
[23:56:49] <ag4ve> echo 'j = { name : "mongo" }' | mongoimport --db mydb --collection contacts --stopOnError --dbpath ./db -
[23:57:37] <joannac> what are you trying to do?
[23:58:25] <ag4ve> i want to put some dns query info into a db right now, but i generally want to have easy access to nosql db from a shell for general info analysis
[23:58:54] <joannac> use the mongo shell
[23:59:15] <ag4ve> i can make dns queries from within the shell?
[23:59:44] <ag4ve> s/the shell/the mongo shell/