PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Sunday the 22nd of February, 2015

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:07:51] <bros> Which is better? 1 query with possibly 200 or conditions, or 200 single queries?
[00:08:31] <bros> SELECT status FROM order_status WHERE id IN (select id FROM open_order)
[00:09:07] <bros> db.collection.find({ '$or': [{ id: 1}, {id: 2}...]})
[00:50:00] <bros> Is it worth it to put a compound index on something you always have to query to check whether it exists or not anyways?
[00:51:35] <preaction> why not just find({ 'status': 'open' })
[01:11:09] <kexmex> 1 query is better ofcourse
[01:11:51] <AWizzArd> I have one collection of 73 mio docs. I installed an ensureIndex({url: 1})
[01:11:53] <AWizzArd> Now I am running `db.coll.count({url: {$regex: /^http:/i}})` and this takes a veerry long time.
[01:11:56] <AWizzArd> Is this line of thought right: when all 73 mio URLs start with "http:" then having an index won’t help. Mongo has to iterate through all 73 mio entries on disk to count them.
[01:20:58] <kexmex> AWizzArd: cause case insensitive i bet
[01:21:34] <kexmex> why dont you lowercase then before you insert
[01:22:22] <kexmex> also, can't you do db.collection.count({url:/^http:/})
[01:22:29] <kexmex> instead of using $regex
[01:24:58] <AWizzArd> kexmex: I didn’t know this kind of notation, this {url: /^http:/} - I guess this is syntactic sugar for the regex version I used above?
[01:25:27] <kexmex> no
[01:25:30] <kexmex> i think they are a bit different
[01:25:30] <kexmex> but
[01:25:43] <kexmex> the 'i' at the end is preventing it from using the index i thnk
[01:26:08] <kexmex> (not sure about them being different tho)
[05:08:29] <bros> How do I update a subdocument in an array of another document?
[06:08:31] <mordonez> Hi guys, I have two libraries for mongo, one for scala (reactive mongo with play mongo) and pymongo for python
[06:08:40] <mordonez> I am using pymongo to migrate some data I have in another place
[06:08:42] <mordonez> the thing is
[06:09:14] <mordonez> pymongo saves a field like this "updatedAt" : NumberLong("1424053878000"), while reactivemongo just "updatedAt" : 1424053878000
[06:09:37] <mordonez> how can I save in pymongo without using NumberLong
[07:17:55] <jaitaiwan> bros: you have to iterate over each document in the array and do a $set
[07:38:08] <mordonez> Hi guys, I have this word "ironía" and I want to search using ironia and ironía
[07:38:16] <mordonez> with or withour the í
[07:38:24] <mordonez> how can I deal with that in mongodb
[07:38:25] <mordonez> ?
[08:29:29] <jaitaiwan> mordonez: use regex
[10:22:24] <iksik> morning
[10:31:53] <iksik> db.collection.find().sort({ $natural: -1 }).limit(10) - how can i use this kind of sort on particular nested field?
[14:09:29] <[WiseWatcher-UK]> Hi, can someone please help with mongodump / restore?
[14:12:06] <[WiseWatcher-UK]> Anyone?
[14:14:16] <kexmex> [WiseWatcher-UK]: yea?
[14:16:43] <[WiseWatcher-UK]> Hi kexmex, I've run mongodump on 2.6.0, then mongorestored to v3, but get http://pastebin.com/cHVfnLRx how can I fix it?
[14:17:29] <kexmex> maybe delete .metadata. files
[14:19:31] <[WiseWatcher-UK]> Will I lose the indexes that way?
[14:19:34] <kexmex> yea
[14:19:36] <kexmex> but you can re-create no?
[14:20:02] <[WiseWatcher-UK]> yes, suppose, thanks!
[14:30:30] <kexmex> [WiseWatcher-UK]
[14:30:38] <kexmex> you can prolly use --noIndexRestore
[14:30:43] <kexmex> instead of deleting files :)
[18:13:29] <bros> https://gist.github.com/anonymous/e626592f1e2834bb3749 I can't get update $push to work.
[18:13:56] <OmicroN_> maybe someone in here can help me, fairly new to mongodb, trying to make a query that'll return all documents UNLESS a specific document by id exists then it'll just return that one
[18:18:47] <bros> Do I need to use findAndModify?
[18:19:24] <kali> bros: nope, but you need ObjectId() around the objectid string
[18:19:33] <kali> OmicroN_: not possible. you'll need two queries
[18:19:56] <bros> Damn, you're good.
[18:20:36] <kali> i know
[18:20:50] <OmicroN_> roger kali, what i figured but thought maybe i could get away with using one :p
[18:20:57] <OmicroN_> not what about this kali
[18:21:21] <OmicroN_> even thought i'm trying to pull all documents i'm not really pulling all documents i'm just finding 1
[18:22:07] <kali> show me the queries
[18:22:19] <OmicroN_> well actually nm that wont work either because of my sort probably
[18:22:20] <kali> or the one that does not work
[18:23:01] <OmicroN_> was thinking if i could use a and/or and have two conditions in my query one to look for the specific id, the other condition to basically pull all records
[18:23:23] <OmicroN_> and if the condition to pull the specific id pulls before the other condition then my findone query will still pull the first record
[18:23:51] <OmicroN_> BUT i also sort based on a point system
[18:24:24] <OmicroN_> so if my specific id condition would of pulled first before the condition to pull all, the sort would still throw it off if the specific id condition doesn't have the highest sort
[18:32:44] <bros> kali, ever heard of Mongoose?
[18:33:30] <ilaron> Hi, I would like to know if there is a possibility in MongoDB to work with dynamic collections ?
[18:48:35] <kali> bros: unfortunately, yes
[18:48:49] <bros> kali, what makes you say that?
[18:49:36] <kali> bros: i don't think the best of the node ecosystem in general
[18:49:52] <bros> what about the language itself?
[18:50:02] <bros> language, engine, whatever you want to call it
[18:50:13] <kali> bros: the langage is terrible
[18:50:25] <bros> what do you use instead
[18:50:33] <bros> what makes it terrible?
[18:50:57] <kali> that's off topic
[18:51:07] <bros> may I DM you?
[18:52:28] <kali> i'm not sure just it's relevant, my opinion on JS are not that ground breaking :)
[18:56:50] <bros> What is an alternative though?
[18:59:16] <kali> about anything would do, really. what niche are we talking about ?
[19:00:00] <bros> web app server
[19:00:08] <bros> What's the proper way to use a unique index:
[19:00:16] <bros> insert and catch error
[19:00:19] <bros> or count before hand, then insert
[19:00:32] <kali> well, play framework, rails, django
[19:00:54] <kali> and about a dozen other, even without considering the php galaxy
[19:01:04] <bros> If it weren't for callbacks, Node would blow all of those out of the water in my opinion. Programming wise at least.
[19:01:13] <bros> Performance/resources may be a different story.
[19:03:32] <kali> insert and catch is the best option imho
[19:07:17] <bros> db.accounts.find({_id:ObjectId('54ea23d2f94bdbc35215db65')}, { stores: { '$elemMatch': { 'name': 'name'}}});
[19:07:19] <bros> What am I doing wrong?
[19:07:35] <bros> I can't insert and catch using update :/
[20:13:41] <Angela_d2> ?
[20:44:17] <jayjo> In order to insert json as a bulk write operation (~200mb at a time), can I access files in my directory through the mongo shell?
[20:44:36] <jayjo> Or am I better off using a driver and my language of choice (pymongo)
[20:51:56] <Angela_d2> am i able to get all messages from a specific user with this schema? http://pastie.org/9972104
[21:06:51] <benb> hey all
[21:07:05] <benb> $push seems to not work correclty for me
[21:07:12] <Guest51704> I have tried a bunch of different methods
[21:07:58] <Guest51704> db.users.update({"_id":ObjectId("54e664c4e7c3b4d3b5413e39")},{$pull:{“ItemsToRemove”: {id:"ChIJIQBpAG2ahYAR_6128GcTUEo"}}},{ multi: true })
[21:08:18] <Guest51704> it return successful
[21:08:33] <Guest51704> but once I look at the record the items in that ‘ItemsToRemove’ array have not been remvoed
[21:10:14] <gaby__> Hey guys, I am quite new to mongodb and I have this question about updating nested documents. Got a gist there with the concern and a code sample : https://gist.github.com/gabriel-dehan/09d94c7b5e8ab6496c1d
[21:10:18] <gaby__> Thanks :)
[21:40:52] <gaby_> Hello guys, kinda new to mongodb and have a question about updating nested documents. Everything is in the gist : https://gist.github.com/gabriel-dehan/09d94c7b5e8ab6496c1d
[21:40:56] <gaby_> Thanks a lot :)
[21:59:52] <bros> gaby_, look into elemMatch
[21:59:56] <bros> I could be wrong.
[22:03:37] <gaby_> bros, don't think this will do but thanks for the insight :)
[22:06:40] <joannac> gaby_: elemMatch is exactly what you want.
[22:06:50] <joannac> why doesn't elemMatch work for you?
[22:07:47] <Guest51704> uggg
[22:08:04] <Guest51704> $pull should remove a single item from my array but it does nothing
[22:08:14] <gaby_> Maybe it is then I might have miss understood how it works. It seems to help to refine the query to get the document, but how does it allow me to update a nested object according to its fields ?
[22:08:15] <joannac> Guest51704: gist?
[22:09:01] <Guest51704> here you go joan: http://stackoverflow.com/questions/28663273/pull-mongodb-is-not-removing-items
[22:09:01] <joannac> gaby_: http://docs.mongodb.org/manual/reference/operator/update/positional/#update-values-in-an-array
[22:09:15] <gaby_> Thanks, will read :)
[22:09:22] <joannac> Guest51704: my nick is "joannac", not "joan"
[22:09:38] <Guest51704> ah sorry!
[22:09:38] <joannac> most irc clients will tab complete nicks
[22:09:45] <Guest51704> joannac: yep
[22:09:47] <Guest51704> gotcha
[22:10:14] <gaby_> Irssi reads it well :) Anyway thanks for the read it is indeed exactly what I want
[22:10:18] <gaby_> Cheers joannac :)
[22:10:45] <joannac> Guest51704: your "itemsToRemove" does not have an _id field
[22:10:59] <Guest51704> here is an updated gist: https://gist.github.com/theprojectabot/fa05647bcf66a0d7d237
[22:11:32] <joannac> Guest51704: sigh. you are not the first person to make this mistake
[22:11:46] <joannac> you want "ItemsToDelete.placeId"
[22:11:55] <Guest51704> joannac: ahh so dot syntax it.
[22:12:36] <joannac> the only time you should be doing something like a: {b:1, c:1} is:
[22:13:02] <joannac> 1. If you are absolutely sure that's exactly how it looks (fields, types, *order of fields*
[22:13:17] <joannac> and 2. If you know your driver will not reorder fields, recast types, etc
[22:13:26] <joannac> (so really, never)
[22:13:51] <Guest51704> ah ok. Im a little confused as I am not doing a {b:1, c:1}
[22:14:42] <Guest51704> I thought Im just finding the ‘ItemsToDelete field (its an array) on my user doc, then $pull any sub fields that match the placeId
[22:15:30] <Guest51704> error I receive when doing “ItemsToDelete.placeId” => ‘cannot use the part (ItemsToDelete of ItemsToDelete.placeId) to traverse the element’
[22:19:38] <Guest51704> joannac: yeah seems It errors out when trying to do ‘ItemsToDelete.placeId’
[22:21:33] <joannac> gist?
[22:22:04] <Guest51704> https://gist.github.com/theprojectabot/fa05647bcf66a0d7d237
[22:22:12] <Guest51704> joannac: updated
[22:22:51] <joannac> you forgot the quotes
[22:23:39] <Guest51704> joannac: woops
[22:23:55] <Guest51704> joannac: i didnt on the test but yes on the gist, gist is updated
[22:25:54] <Guest51704> joannac: so yeah with quotes I still get that ‘cannot use the part (ItemsToDelete of ItemsToDelete.placeId) to traverse the element’
[22:26:43] <Guest51704> joannac: I have also updated the gist with the full error
[22:28:58] <joannac> wow, $pull is the one exception to that rule
[22:29:01] <joannac> what the hell
[22:29:14] <joannac> Guest51704: okay, my apologies, I steered you wrong
[22:29:31] <joannac> db.users.update({"_id":ObjectId("54ea5683681b242a284cbe05")},{$pull:{"ItemsToDelete": {placeId:"ChIJIQBpAG2ahYAR_6128GcTUEo"}}},{ multi: true })
[22:29:36] <joannac> that's what you want
[22:30:37] <Guest51704> joannac: thanks I try that but when I do a refresh on that user again, its ItemsToDelete array still has all the records in it
[22:30:50] <Guest51704> instead of multi pulling(and removeing) all 3 it just has all three still
[22:31:32] <Guest51704> joannac do i have to do a secondary opertation to have the elements of that ItemsToDelete array removed? after the $pull?
[22:32:27] <joannac> I copied the document in your gist
[22:32:31] <joannac> wait
[22:32:39] <joannac> so, you didn't give me an ObjectId
[22:32:48] <joannac> the ObjectId in there is my objectId
[22:32:57] <joannac> replace it with the ObjectId for your document
[22:33:09] <Guest51704> …right lol
[22:33:39] <Guest51704> I swear that I had typed the same thing…before asking this question joannac
[22:33:44] <Guest51704> thank you for your help
[22:33:49] <Guest51704> the array is now empty
[22:34:01] <joannac> np, i know the feeling
[22:34:18] <joannac> "i swear that was the exact same thing I typed 30 mins ago at the start of this mess wth?!"
[22:35:26] <Guest51704> ok well will see if this translates into my golang
[22:35:27] <Guest51704> thanks
[22:35:28] <path> any/window 7
[22:35:29] <Guest51704> again
[22:35:31] <path> baeh