PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Monday the 24th of December, 2012

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[02:58:12] <jeremy-> Can anybody see the error in this php mongocollection query: $SearchOrParams = array( '$or' => array( array("dwf" => array( '$in' => $wla_array)), array("dwl" => array( '$in' => $wlf_array)), array("dwa" => array( '$in' => $wll_array))));
[02:58:35] <jeremy-> produces json_encode output {"$or":[{"dwf":{"$in":["bluray","store"]}},{"dwl":{"$in":["sci-fi","game"]}},{"dwa":{"$in":["3d","funny","trailer","online"]}}]}
[02:58:56] <jeremy-> Is it something to do with using $or and then $in not working? Seems unlikely, im assuming the nested syntax is confusing me
[03:07:07] <joe_p> trying to aggregate my shard chunks to look at distribution by ns, shard and the sort isnt working- db.chunks.aggregate( { $group : { _id : { ns : "$ns" , shard : "$shard"} , chunks : {$sum : 1} }, { $sort : {"_id.ns" : 1, _"id.shard" : 1 } } } )
[03:07:32] <joe_p> mongos> db.chunks.aggregate( { $group : { _id : { ns : "$ns" , shard : "$shard"} , chunks : {$sum : 1} }, { $sort : {"_id.ns" : 1, "_id.shard" : 1 } } } )
[03:17:28] <jeremy-> nvm, got there after 20 hack attempts
[06:49:27] <salentinux> hi guys, to do subqueries I use to save intermediate results in an array and then use it with $in operator. The question is, how much data can an array have?
[18:19:05] <silverfix> hello
[18:19:26] <silverfix> is there a way for prioritize a condition in $or ?
[18:48:45] <Goopyo> silverfix: they way they are nested
[18:51:53] <silverfix> Goopyo: thank you :)
[18:52:54] <silverfix> what is the best query? 1) db.col.find().sort('field':-1) or db.col.find({'$exists':'field'}).sort('field':-1) ?
[18:53:29] <Goopyo> field is indexed right?
[18:53:46] <silverfix> right
[18:54:08] <Goopyo> then for sure the first one
[18:54:20] <Goopyo> wait
[18:54:34] <Goopyo> you're trying to only return fields that have 'field' set?
[18:54:42] <silverfix> no
[18:54:55] <silverfix> that is, not only
[18:55:18] <Goopyo> the second one {'$exists' : 'field'} only returns the ones with field set
[18:55:19] <Goopyo> I believe
[18:55:37] <Goopyo> consider find() a filter, everything in there filters the results
[18:56:12] <silverfix> yeah
[18:56:26] <Goopyo> find({'exists'…) means from all records give me the ones that have this field set
[18:57:15] <Goopyo> the first one gets all the records and then sorts em
[18:57:54] <silverfix> yes
[18:58:00] <silverfix> so what is the better query? the first?
[18:58:11] <Goopyo> what I'm saying is that they're different queries
[18:58:28] <Goopyo> 1) Retrieves all records, sorts by field, those without field fall the the bottom or top
[18:58:44] <Goopyo> 2) Retrieves only records with field set, and sorts them
[18:58:55] <silverfix> yes, I know
[18:59:16] <silverfix> 1) performs better ?
[18:59:53] <Goopyo> 2 performs better because it reads less of the disk
[19:00:37] <Goopyo> 1 is a fully collection read so its as unoptimized as it probably gets
[19:01:02] <silverfix> mmm..
[21:07:36] <USvER> Hi, i have an array of subdocuments. How can i query items containing subdocument with specified fileds and can contain other fields.
[21:13:49] <USvER> So if i have collection with two documents: {subDocs:[{a:'1',b:'2'},{a:'2',b:'2'}]} and {subDocs:[{a:'1',b:'2'},{a:'2',b:'1'}]}. How can i query for documents that contain subdocument with {a:'2',b:'2'} i this case only first document... and {a:'2',b:'1'} wich will be only second....
[21:15:18] <USvER> Fon now if i test for {subDocs.a:'2', subDocs.b:'2'} i will get both documents...
[21:17:38] <USvER> i nead some sort of DotNotation mixed with subdocument query... wich will test for EXACT match....
[21:19:20] <USvER> I mean i don't need that "EXACT" match thing.... i just need to test subdocument for multiple fields...
[21:20:13] <USvER> Can anybody help me? Please...
[21:24:52] <USvER> This is something like "Array contains object with fields a equals to '2' and b equals to '2' but can contain other fields"
[21:26:41] <Zelest> How can I write a string to a file in GridFS using the PHP-driver?
[21:27:15] <Zelest> Or do I have to write it out to a file first and then call storeFile() ?
[21:27:58] <Zelest> Ah, storeBytes!
[21:27:59] <Zelest> :-D
[21:33:16] <USvER> Somebody?
[21:35:21] <Zelest> USvER, i'll see if I can figure it out. :-)
[21:35:50] <USvER> I think this one is really tough
[21:38:36] <USvER> I really need this... and if there is no answer i would need to go relational way... for me this is like startover
[21:40:03] <fommil> is there a function which will sanitise a (Java) String – intended for literal matching in an aggregate – so that it can't contain any malicious characters?
[21:40:47] <Zelest> USvER, I'm more or less a newbie, but yeah, trying to figure it out :)
[21:41:54] <USvER> Zelest, i'm newbie too... and i guess this one requires more experience in mongo... Thank you for your help....
[21:44:04] <Zelest> Hmms, might be me who's retarded, but I thought that $elemMatch was the right tool here..
[21:44:11] <Zelest> but it doesn't seem to work the way I expect it to.
[21:45:41] <USvER> I think of that too...
[21:46:40] <USvER> Matching arrays must have at least one element that matches all specified criteria
[21:46:41] <Zelest> oh
[21:46:48] <Zelest> this one was easy
[21:46:55] <Zelest> db.test.find({'subDocs.b': "1"})
[21:46:59] <USvER> So it works?
[21:47:01] <Zelest> or what am I missing?
[21:47:19] <USvER> I nead this: "Matching arrays must have at least one element that matches all specified criteria"
[21:47:20] <Zelest> I was matching where b was 1 .. not "1" ..
[21:47:41] <USvER> matches ALL criteria
[21:47:55] <Zelest> aah
[21:47:58] <USvER> So if i have multiple fields... i can test them all
[21:48:09] <Zelest> well, add $and ?
[21:48:09] <USvER> "Array contains object with fields a equals to '2' and b equals to '2' but can contain other fields
[21:48:27] <USvER> =\
[21:49:03] <USvER> i think $elemMatch i the unswer
[21:49:08] <USvER> answer*
[21:49:25] <USvER> But can't get it to work.
[21:49:30] <USvER> Now tryin
[21:49:39] <Zelest> db.test.find({'subDocs': { $elemMatch: { a: "2", b: "1" }}})
[21:49:57] <USvER> returns only one document?
[21:50:05] <Zelest> yeah
[21:50:07] <USvER> from 2?
[21:50:10] <USvER> NICEEEE
[21:50:17] <USvER> You my hero :D
[21:50:29] <Zelest> Far from it :P
[21:50:45] <USvER> That was easy... =\ I'm total newb
[21:50:45] <Zelest> I was failing to match the string..
[21:50:55] <Zelest> 2 != "2"
[21:51:02] <USvER> Oh...
[21:51:17] <USvER> Thank you....
[21:51:20] <Zelest> Hence me not understanding $elemMatch first :)
[21:51:26] <Zelest> You're welcome :D
[21:51:35] <Zelest> And thanks you too.. seeing I learned something as well :D
[23:23:05] <weeb1e> Oh god
[23:23:12] <weeb1e> This is hte worst time for major issues