PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Sunday the 16th of February, 2014

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[01:24:23] <hpekdemir> hi all. how would I remove this user (I made a mistake with function "db.addUser"): { "_id" : ObjectId("53000b4f6401744411cd375c"), "user" : { "user" : "blabla", pwd: ....} }
[01:24:41] <hpekdemir> I typed with wrong syntax.
[01:24:59] <hpekdemir> so now I have in "user" a document with "user": "name"
[01:25:33] <hpekdemir> and removeUser function is declared as: removeUser( username ) this.getCollection("system.users").remove({user: username});
[01:27:56] <hpekdemir> ok got it. I just did a "db.system.users.remove()"
[01:28:01] <hpekdemir> I had only one in it.
[01:50:10] <granger915> so i'm new to mongodb and rockmongo...i'm totally confused...i kinda understand the json format, but i can't seem to figure out how to write to a file like you can with phpmyadmin
[02:06:22] <granger915> is anyone alive in this channel?
[03:40:16] <ramnes> granger915: it's late
[03:44:08] <EldonMcGuinness> hey everyone, was trying to use upsert with a custom _id but it does not seem to take the _id I specify in the query during an insert. I tried looking around but some people say it should work while others do not. Any one here have an idea on it?
[03:53:03] <EldonMcGuinness> welp nevermind, looks like you can put it in the set section, didn't think you could
[04:14:29] <tripflex> yeah you can set _id to whatever you want
[04:14:39] <tripflex> if you don't it will create a random unique one of its own
[04:15:13] <EldonMcGuinness> yea I was reading that it would cause an error if you try to update with _id set since _id should not be changed
[04:15:39] <EldonMcGuinness> but apparently that is not the case :-) Not that I'm changing the _id though heh
[05:29:43] <langemann> Heya, anyone around? I have a page with 8 documents, I want to click a button and retrieve new 8 documents based on the objectID of the 8th previous document. Bad/good idea? :)
[05:36:11] <cheeser> skip/limit
[05:36:12] <cheeser> mv cheeser /dev/bed
[07:20:29] <dachi> to check if document has any occurances of a specific field, currently in rails I'm doing Model.where(field: 'smth').count > 0
[07:20:41] <dachi> is there better way like Model.hasAny(field: 'smth')
[07:20:42] <dachi> ?
[07:20:48] <dachi> tnx
[07:38:23] <banner_> dachi, would Model.find({field: 'smith'}) work?
[07:38:55] <dachi> no, Model.find takes only ObjectId
[07:39:44] <dachi> there's hasAny with MongoDb at PHP with
[07:39:50] <dachi> I mean in cakePhp framework
[07:40:07] <dachi> I wondered if there was something similar in rails too. thanks anyways
[07:40:58] <banner_> yeah is Model.find a separate function to db.collection.find?
[07:44:41] <dachi> so.
[07:44:53] <dachi> Model.find('123123123', '1231231')
[07:45:30] <dachi> can be same as collections[:model].find({ _id: { '$in' => [ '123123123','123123123' ] } } )
[07:47:08] <dachi> but Model.where(field: '123123').find(123123) is same as collections[:model].find({_id: '123123', field: '123123'})
[07:47:58] <dachi> so Model.where(field: '123123').count is like that, but it queryies every field and then counts :(
[07:50:14] <banner_> but if you did collections[:model].find({field: 'attr'}).cout() that would just count the matches right?
[07:52:02] <dachi> but it would find every field that has field:attr
[07:52:15] <dachi> other one would stop on the first occurance
[07:52:21] <dachi> and tell me that there IS at least one
[07:55:03] <banner_> oh
[07:55:15] <banner_> huh
[11:51:27] <fl0w> So I have the following setup - pseuduo-ish: https://dpaste.de/5usM The plan is that I'll be finding the whole document where I am included in _authors. Then I'd like to reduce all articles where I'm not included. The query aside, is this a good approach?
[11:52:22] <fl0w> (mongodb firsttimer, trying to comprehend schema design comming from a typical relational database)
[11:53:00] <kali> well, at least, you're considering the querying part
[11:53:17] <kali> which is key in designing for mongodb and nosql
[11:54:46] <fl0w> "at least" - meaning I'm way off?
[11:55:20] <kali> nope. i am just not sure i understand what you're trying to do
[12:00:06] <fl0w> Oh, sorry. I'll try to rephrase my question. Is my example - generally speaking - a valid approach to schema design? I figure I'll need to ensure indexes on _authors: [ ObjectId ], and I will not ever be close to the 16mb limit (this is a pseuduo example - real world scenario isn't article related). I'll be juggling 1..~20 articles for each document.
[12:00:57] <kali> that part sounds fine. i was a bit more worried about the "reduce all articles where I'm not included.
[12:01:00] <kali> " bit
[12:02:22] <fl0w> Basically I dont want to show unrelated articles to a specific user - granted I can do this at app level.
[12:04:24] <fl0w> kali: Is mongodbs "map reduce" applicable for the reduce scenario? (haven't really tried it yet)
[12:04:34] <kali> avoid it
[12:04:57] <kali> but the aggregation pipeline might help
[12:05:37] <kali> map/reduce is more flexible, but slower than the pipeline, so anything that can be done with the pipeline should be done with it
[12:07:02] <fl0w> Alright, I'll take a read and a stab at testing this - and I'll figure out if my setup holds true to what I'm trying to accomplish! Many thanks kali.
[12:07:54] <kali> you're welcome
[12:16:57] <fl0w> kali: The grouping part of an aggregation seems to be the recuding that I want! Aww yee. However, should I be worried that I'll be indexing a JSON array? (my usecase would be equivalent to how tags are show cased in random mongodb examples)
[12:18:01] <fl0w> But it'll be an in-app join (since I need to normalise users b/c of other circumstances)
[12:20:16] <kali> indexing a field in a array of object is just fine, so that part is fine
[12:22:05] <orweinberger> Let's say I have a mongod instance with a 1GB database in it. Now I create a mongos instance and add that db as a shard. Now I set up another empty mongod instance and add that one to the mongos as a shard, will data from first mongod be divided to the new shard as well? or only new data from that point on will be sharded?
[12:23:04] <fl0w> Sweet. I'm not working with massive data anyway (actually, it's quite miniature) - but I'm new so I'd like to get the cogwheels working correctly (in my head)
[12:23:23] <kali> orweinberger: you need to enable shard on the databases and on the collections you want shardedn but then the balancer will start move things around
[12:23:54] <orweinberger> kali, OK, but will it start from that point onwards or will take also the data that is currently in the old shard and split it to the new shard?
[12:24:42] <kali> yes it will rebalance old stuff too
[12:24:47] <orweinberger> cool, thanks.
[13:21:10] <tsousa> how can i iterate over the all db? or how can i use query to match an array in the db?
[13:25:24] <Batmandakh> Good day fellow Mongoers!
[13:25:41] <Batmandakh> I want to ask a db design best practice...
[13:26:04] <Batmandakh> So, I'm developing a system that could become bigger...
[13:26:27] <Batmandakh> I'm thinking of 2 collections those are "users" and "items"
[13:26:56] <Batmandakh> specially item could cause problem if did it in this way
[13:27:34] <Batmandakh> Items have some indexes such as id, categories and status,.. etc
[13:27:49] <Batmandakh> one user could have millions of items.
[13:28:37] <Batmandakh> so, what about this? if i get thousands of users, each have millions of items... what its future?
[13:28:49] <Batmandakh> I'm sorry for my bad English :-D
[13:29:42] <Batmandakh> Will the items collection slow down my system?(in other words my db's work?)
[13:30:43] <Batmandakh> I'm think I must insert user id into items collection for link...
[13:31:48] <Batmandakh> I'm trying hard to do it most clear and optimal way to achieve this issue... later I could replicate and shard my infrastructure when the times come...
[13:32:59] <Batmandakh> the system will count and analyze items very frequently...
[14:51:39] <hexdump> hi is there a way to set index on all collections in database? in one command?
[16:01:25] <bobinator60> could someone take a look at my query & explain() and tell me why indexOnly is not True?
[16:01:26] <bobinator60> http://bpaste.net/show/slRYO9KPL25sUTb8pVVw/
[16:02:32] <bobinator60> i'm also curious about why the indexBounds for attributes.kind is 1:1
[20:03:08] <squeakytoy> I have a question, for maybe you guys who has used mongodb more.. seriously. Object ID is autogenerated based on a lot of factors, right? And its pure numeric, right? How big can that number be?
[20:03:59] <kali> squeakytoy: http://docs.mongodb.org/manual/reference/object-id/
[20:05:34] <squeakytoy> second question is. is it totally.. reasonable to use that object is a public id for sites?
[20:05:50] <squeakytoy> or is that a big no no?
[20:06:07] <squeakytoy> for example: domain.com/user/507f191e810c19729de860ea/
[20:06:54] <fl0w> squeakytoy: You could, but wouldn't it be nicer to do domain.tld/user/:username instead?
[20:07:57] <squeakytoy> ive been thining about that aLOT
[20:08:33] <squeakytoy> the problem is, correct me if you have another opinion, is that it will be a racecondition. someone will take domain.com/user/obama/ when they are not obama
[20:08:50] <squeakytoy> wont that just promote identity thefts?
[20:10:02] <squeakytoy> Twitter has now "verified" status, which must be a huge time consuming investment
[20:10:34] <squeakytoy> i dont kno
[20:10:35] <squeakytoy> i dont know
[20:10:38] <fl0w> Can't say much in that regard - there's no context. Depends on the service you're planing on providing. However, if you get to twitter size then you can just sell it or buy others to solve that issue :)
[20:11:38] <squeakytoy> usernames?
[20:11:47] <fl0w> the service you're doing
[20:11:51] <squeakytoy> Yea, but as a service provider (twitter) i wont be able to sell
[20:12:16] <squeakytoy> or selling the service entirely? uhm. odd reaction to solve identity thefts?
[20:13:21] <fl0w> squeakytoy: I was kidding (though badly) - because I have no idea what you're trying to do. If usernames are aliases, then it doesn't really matter in my opinion (much like having an alias @ a games forum). If you're doing something more serious, then maybe you're right.
[20:13:49] <squeakytoy> mm
[20:14:21] <squeakytoy> but a mongodb object id is rather long. I could shorten it, but then I would.. actually not make is scalable
[20:14:33] <squeakytoy> if i came up with my own id for documents
[20:16:04] <squeakytoy> correct me if i am wrong,but the whole beauty with object id is that once generated, its pretty unique, hence you do not query the whole database to inject a new document?
[20:16:25] <squeakytoy> in other traditional databases, you need to scan through the whole database in order to make sure the id is free?
[20:18:23] <fl0w> squeakytoy: Either way you'll be going through some kind of index.
[20:25:48] <leifw> squeakytoy: most databases just use a regular autoincrement value, this doesn't work if you have sharding though, you could generate the same _id on two machines and then migrate those docs' containing chunks together and lose _id uniqueness
[20:26:10] <squeakytoy> for most databases right?
[20:26:12] <leifw> objectid is only 12 bytes, it's not "rather long"
[20:26:16] <squeakytoy> hence why mongodb has object id?
[20:26:50] <leifw> I believe that's why they created object id, it's partially an autoincrement value, partially determined by a unique-ish machine id and PID
[20:27:36] <squeakytoy> so, if you have multiple mongodbs, the generated ids are so unique so they are probably safe to insert it directly?
[20:28:00] <leifw> yep
[21:51:22] <Benjarmin> db.users.insert( { name: "skot", hostname: "cpe-24-164-133-113.nyc.res.rr.com" } )
[22:44:10] <mboman> How do I delete a specific key from a document?
[22:45:05] <joannac> mboman: $unset
[22:48:14] <mboman> joannac, so the following would remove the 'yara' key if it is empty? db.vxcage.update({'yara':{$size:0}}, { $unset: {'yara':""}, { multi: true }})
[22:48:54] <mboman> updated: db.vxcage.update({'yara':{$size:0}}, { $unset: {'yara':""}}, { multi: true })
[22:49:01] <joannac> mboman: no, $size is array size
[22:49:27] <joannac> if that's what you mean, then yes
[22:49:38] <mboman> joannac, yes, I know. if I store a empty array I want to remove the key
[22:50:20] <joannac> then yes
[22:50:27] <bobinator60> what do i specify in hint() for mongoengine in order to recommend a specific index?
[22:51:08] <joannac> bobinator60: you can hint a specific index in the shell. not sure how mongoengine handles that
[22:51:34] <bobinator60> joannac: right, not much documentation on what mongoengine wants :(
[22:52:05] <bobinator60> when i supply the index name, i get 'bad hint'
[22:52:06] <mboman> joannac, many thanks for your assistance. Related question: what is the best way to append items to an array?
[22:53:06] <joannac> bobinator60: http://docs.mongoengine.org/en/latest/apireference.html#mongoengine.queryset.QuerySet.hint
[22:53:16] <joannac> mboman: $addtoset ?
[22:53:28] <joannac> mboman: or $push
[22:53:36] <bobinator60> joannac: yes, i read that, and everything else that google suggests
[22:55:12] <joannac> bobinator60: that says "give the field name"
[22:55:27] <mboman> joannac, $addtoset seems to be most accurate to what I want to do (add new signature hits to a sample)
[22:55:44] <bobinator60> i have a multi-field index
[23:01:22] <bobinator60> joannac: i can put in one field, like this: hint( [ ('fieldname', 1) ] )
[23:12:14] <bobinator60> ok, i figured it out. pm me if you want the solution
[23:12:37] <joannac> bobinator60: why don't you just put it in channel?
[23:13:12] <bobinator60> i thought since its mongoengine, it would be OT, but i'm happy to do so:
[23:14:36] <bobinator60> hint([ ('field1', 1), ('field2', 2)]) where field1 and field2 must be exactly what is found in the index specification
[23:14:55] <joannac> okay
[23:15:03] <joannac> same order as in the index?
[23:15:28] <bobinator60> http://bpaste.net/show/l4N5vPvuCIV0zh3IFzCJ/
[23:15:42] <bobinator60> in the 'key' portion, not the 'name'
[23:16:14] <bobinator60> joannac: not sure if order is important, but i did use the same order
[23:16:51] <joannac> bobinator60: did you specify all the fields, or just some of them?
[23:16:56] <bobinator60> the unfortunate part is that i am only requesting the _id back, but it is not using it as a covered query.
[23:17:05] <bobinator60> yes, all the fields
[23:17:16] <joannac> bobinator60: okay, thanks
[23:17:36] <bobinator60> so I am getting 1696 records back, but it takes 15.8 seconds to iterate through the cursor :(
[23:17:59] <bobinator60> and indexOnly is false
[23:19:16] <joannac> but the query should be able to be covered by that index?
[23:20:25] <bobinator60> here's the query plan: http://bpaste.net/show/GaNKS1juLIPnc9S13nRT/
[23:20:38] <bobinator60> not sure why its bailing on the _id
[23:21:01] <bobinator60> otherwise it looks perfect
[23:21:42] <bobinator60> 111 milliseconds to run the query, and 20+ seconds to iterate through it :(