PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Friday the 24th of April, 2015

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:00:18] <Boomtime> ToeSnacks: what version of mongodb?
[00:02:39] <ToeSnacks> Boomtime: 2.4.12
[00:09:15] <ToeSnacks> It has said "chunks" : NumberLong(524) for the entire time
[00:54:16] <Boomtime> ToeSnacks: hmm.. 2.4.12 is a bit tricky to inspect, can you gist/pastebin sh.status(), sh.getBalancerState() and sh.isBalancerRunning()
[00:54:55] <Boomtime> balancer state is an aspect that was specifically addressed in 2.6+ due to it being a bit difficult to get a good view of exactly what was happening
[03:43:21] <arussel> what does that mean: "exception: The argument to $size must be an Array, but was of type: EOO"
[03:43:33] <arussel> what is the type E00 ?
[04:05:00] <joannac> arussel: end of object
[04:12:46] <arussel> joannac: thanks
[05:04:18] <Gevox> Hi
[05:07:02] <Gevox> I'm trying to reterive a field into a document using one of the keys inside a document, i.e get email of user who has id of "x". The output is given in a json format, how can i retreive the value only and store it into a string? this is the output { "email" : "medo@live.com"}
[05:07:52] <Gevox> It actually returns a cursor, and the output is the result of .hasNext()
[05:11:30] <joannac> Gevox: for each element in the cursor, pull out the value of the element "email"
[05:12:03] <joannac> in pesudo javacode: while cursor.hasNext() { mydoc = cursor.next(); myemail = mydoc.email }
[05:12:16] <Gevox> jonnac: I'm stuck really, this is what i want. Can you take a peek on my method? http://pastebin.com/bs3wWguv -- exactly line 19 is what i want to create the object.
[05:13:14] <joannac> Gevox: print out the entire object
[05:13:31] <joannac> you're getting the wrong field or something
[05:14:09] <Gevox> jonnac: I'm getting the right field man, but the format isn't correct. I'm getting a cursor.hasNextt() return which is like this { "email" : "medo@live.com"}
[05:14:17] <Gevox> Key, Value pairs. What i need is just the value
[05:15:25] <joannac> so parse out the value?
[05:15:40] <Gevox> how can i do this? It gives me an exception
[05:16:20] <Gevox> String email = emailCurosr.next().get("email").toString();
[05:16:48] <joannac> what's the exception
[05:16:52] <Gevox> this is my attempt so far to get the value, however, it returns a json
[05:17:03] <Gevox> EXCEPTION: java.util.NoSuchElementException
[05:17:23] <joannac> that suggests there's no "email"
[05:18:14] <Gevox> nvm I FOUND IT
[05:18:24] <Gevox> thanks you gave me the hint
[05:18:33] <Gevox> at this line System.out.println("OUTPUT: " + emailCurosr.next().get("email").toString());
[05:18:37] <Gevox> oh sorry not this one
[05:18:51] <Gevox> System.out.println("OUTPUT: " + emailCurosr.next());
[05:19:05] <Gevox> this moves the cursor 1 step and so i get the document
[05:19:21] <Gevox> and in my failed attmpt to pirnt the email value i do one more cursor movement, so i point to a null value
[05:19:29] <Gevox> at this line excatly String email = emailCurosr.next().get("email").toString();
[05:19:47] <Gevox> I should have do all in the same line like this System.out.println("OUTPUT: " + emailCurosr.next().get("email").toString());
[05:21:40] <Boomtime> Gevox: why do you need to do everything in a single line? are you not allowed to use carriage-returns?
[05:22:30] <Boomtime> if you do one method call at a time you will be able to tell which one is failing
[05:22:48] <Gevox> I don't know what is carriage-returns, sorry
[05:22:57] <Boomtime> DBDocument doc = emailCurosr.next()
[05:23:00] <Gevox> or i might do, but i don't know that this is its name
[05:23:12] <Boomtime> (actually i don't know what the type is that next() returns)
[05:23:20] <Boomtime> then:
[05:23:42] <Boomtime> BsonObject email = doc.get("email")
[05:23:47] <Boomtime> then:
[05:23:50] <Gevox> Boomtime: .next return http://i.imgdady.com/cr0f74.jpg
[05:24:15] <Boomtime> DBObject, there you go
[05:24:28] <Boomtime> DBObject doc = emailCurosr.next()
[05:24:35] <Boomtime> DBObject email = doc.get("email")
[05:24:50] <Boomtime> at least this way you will know which method is failing
[05:26:18] <Gevox> okay
[05:27:15] <Boomtime> btw, if you print out each step via toString(), you might be able to figure out what is happening at each step
[05:27:27] <Boomtime> eg. System.out.println( doc.toString() )
[05:27:41] <Boomtime> this should give you some idea of what your working with at each point in your code
[05:27:56] <Gevox> yeah i did this and it helped actually
[08:00:06] <Gevox> Hi, i'm making a method which retreives all of the documents found into a mongoDB and stores them into an ArrayList, finally return that list. However, it seems that the method only reads the 1st document in the collection only and it does not even store it into the specified list. Line 27 is never printed. Can someone figure out the issue? http://pastebin.com/cJd0gePa
[08:26:27] <MongoUser001> Hi there. Does anyone know what "writeConflicts" means in a log
[08:26:46] <MongoUser001> I have this appearnign in my log and it's hanging my filesystem for some reason ... http://pastebin.com/Rie7pKav
[09:07:49] <Askilada> Hi, I'm working on a project using mongodb-ruby driver. I'm have googled how to use ISODate in a Aggregation, but I can't figure how in rails, I can do it in my mongoDBQuery
[09:08:08] <Askilada> any sugg?
[09:17:39] <luffy_> Is there a way for mongo to select between more than one reduce function?
[09:19:24] <luffy_> (im using django) so in a function i run a map_reduce , and depending on the function variables i want it to select between a set of reduce_functions (1 map, several reduce)
[10:28:23] <rearth> Hi, how do i do a find with regexes on one field with AND, see http://pastebin.ca/2980173
[10:31:24] <Derick> find( { $and: [ { text: /GA/ }, { text: /peter/ } ] } );
[10:31:25] <Derick> I think
[10:33:25] <rearth> This works, thanks!, I didn't get the $and syntax working
[10:33:50] <Derick> please note that with a regular expression, it's not going to use an index
[10:33:59] <rearth> i was trying something like {text: $and[ .. ]}
[10:34:23] <rearth> ok, thats fine with me
[10:37:04] <StrangeBrew> hi, i'm new to mongo, and I was wondering..why would someone use a service such as mongolab/mongohq instead of running it on his server?
[10:37:53] <Derick> for the same reason you would use AWS instead of your own hardware: maintenance time
[10:38:42] <Derick> but of course, you pay extra for that service
[10:38:45] <StrangeBrew> oh ok, didn't know that maintenance could take so long
[10:39:00] <Derick> it's likely also easier to scale up, as you wouldn't have to wait for new hardware to show up
[10:39:10] <kas84> Hi, I’ve just installed mongodb 3.0.2 on my server, how can I tell which version is running right now?
[10:39:21] <Derick> on the shell: mongo
[10:39:26] <StrangeBrew> thanks Derick!
[10:39:33] <Derick> kas84: and then on the mongo shell: db.version()
[10:39:58] <Derick> StrangeBrew: maintenance isn't that much, but you need expertise, and it's not 0 time
[10:40:14] <kas84> okay, that migrates my mongo db from 2.6 to 3.0 verion?
[10:40:36] <Derick> kas84: it doesn't migrate anything - but you wouldn't really need to anyway
[10:41:11] <kas84> aha, and is there a way to migrate to the new db engine?
[10:41:24] <kas84> or do I need to start from scratch?
[10:41:27] <Derick> what do you mean by "new db engine" ?
[10:46:18] <sudomarize> can i get a hand"?
[10:47:32] <smogg> I’m working with nested array and I’d like to add-or-update values, can anyone help me how to do that with this kind of collection: https://gist.github.com/smogg/abcf5aff7d02eac265a0 ? I basically want to update user’s value IF he exists in the “players” set, or add new user with value if he does not.
[10:49:34] <kas84> Derick: wired tiger
[10:49:58] <Derick> kas84: ok - are you running a replicaset ?
[10:50:03] <Derick> sudomarize: you need to ask a question
[10:50:22] <kas84> nope, just mongod
[10:51:01] <Derick> kas84: in that case, mongodump with 3.0.2 without WT - stop mongod - start mongod with WT engine - mongoimport
[10:51:31] <kas84> great Derick, thanks
[10:52:00] <Derick> sorry
[10:52:07] <Derick> mongorestore instead of mongoimport
[10:53:08] <sudomarize> Derick: i'm trying to implement a category search feature using mongo as the DB. So far my Category model looks like {name: "Category", parent: "9kh2kjahdfew"}, where Categories.findOne({name: "Category"}).tree() returns the parents and children of that particular category. I've wondering how i can implement an autosearch where it would say "Walls & Fences in Repair work" or "Pies and Pastries in Food", etc
[10:53:51] <sudomarize> currently when users search for a category, it returns only the category name, e.g. "Walls & Fences" (without the context of "repair work").
[10:55:11] <Derick> {name: "Walls & Fences", parent: "Repair Work" } << wouldn't that be your model? Seems trivial that way
[11:34:14] <pamp> Hi guys
[11:34:43] <pamp> how can a execute a unordered batch insert with csharp driver?
[11:34:55] <pamp> I cant find documentation for this
[11:36:42] <mick27> hey folks
[11:37:10] <mick27> anyone around using mongodb and elastic search ? I wonder what are people going to use to move away from rivers starting 1.5
[11:38:16] <Derick> write an oplog tailing script
[11:41:21] <BurtyB> Is there a way to search documentation for old versions ? when I set the the version to 2.6 (via options) and search it reverts to 3.0
[11:57:43] <sudomarize> Derick: would it be better to use the parent._id for the parent key in my document, or does it not matter?
[11:57:58] <mick27> Derick: thx, my dev likes the idea
[12:10:04] <_rgn> I'm inserting a bunch of objects in parallel and getting duplicate key errors for _id, is the right way to always insert sequentally in the same collection or?
[12:18:09] <fl0w> _rgn: are you using ObjectId as primary key?
[12:18:43] <sudomarize> Why can I not set a "parent" key on my document?
[12:19:03] <sudomarize> Even when I try to update a document, and it returns 1, the parent key is still undefined??!?!??!
[12:19:37] <_rgn> fl0w: _id should be ObjectId yes
[12:23:41] <sudomarize> dw
[12:25:03] <_rgn> fl0w: sorry nevermind, looks like the issue is elsewhere
[13:03:24] <razieliyo> hi
[13:03:38] <razieliyo> so, how do I get distinct values from a field-filtered find?
[13:03:48] <StephenLynx> what do you mean?
[13:04:17] <StephenLynx> how do you find out what distinct values you have for the same field?
[13:04:43] <razieliyo> I mean, db.data.find({}, {somefield:1, _id:0}), this has a projection so that only 'somefield' is selected
[13:05:00] <razieliyo> the question is, how to get the distinct values of 'somefield' from that set?
[13:05:18] <StephenLynx> yeah, thats what I said.
[13:05:21] <StephenLynx> let me have a look
[13:05:50] <razieliyo> yep, I tried to take a look at distinct function but I think it has other usage
[13:06:02] <razieliyo> or not sure about how to use it
[13:06:11] <razieliyo> tried adding .distinct("somefield") to that find
[13:06:30] <StephenLynx> http://docs.mongodb.org/manual/reference/operator/aggregation/addToSet/#grp._S_addToSet
[13:06:45] <razieliyo> let's have a look
[13:06:56] <StephenLynx> you can group under a fixed id and group it.
[13:07:11] <StephenLynx> that way you will get the value from all documents
[13:08:02] <razieliyo> good! I'm trying (still too noob :)
[13:09:06] <razieliyo> errr, StephenLynx would this work if the find query is not {} but {otherfield:'value'}?
[13:09:20] <StephenLynx> of course.
[13:09:23] <razieliyo> can I find(...).aggregate?
[13:09:29] <StephenLynx> no, you just aggregate.
[13:09:37] <StephenLynx> they are distinct operations.
[13:09:54] <razieliyo> ok, I think I need to get a deepier understanding of aggregators
[13:10:03] <StephenLynx> a find is an operation where you query and project. an aggregate is a flexible operation where you can do both of these plus a lot more.
[13:10:14] <watmm> One of those "how long is a piece of string" questions, but how long would you say is too long, for a flush time?
[13:10:15] <razieliyo> I see, fine! I've mostly used find
[13:11:00] <StephenLynx> watmm as much as it impacts the application under its regular requirements.
[13:11:29] <watmm> How would you test for that?
[13:12:48] <StephenLynx> you create a benchmark that simulates the regular requirements.
[13:13:09] <StephenLynx> how much concurrent operations are you expecting? what operations you need to realize.
[13:26:10] <Jester01> I wanted to do mongo foo.js --eval 'use stuff from foo.js' but apparently mongo does the eval first ... any workaround ideas?
[13:26:29] <Jester01> apart from using another js file
[13:26:35] <Jester01> or editing foo.js :)
[13:34:50] <Jester01> looks like echo 'stuff using foo' | mongo --shell foo.js could work
[13:59:13] <sudomarize> what is the best method of creating a category system re: http://docs.mongodb.org/manual/tutorial/model-tree-structures/? can i get some advice on this?
[14:43:51] <mick27> anyone using the official docker mongo image around here ?
[15:48:48] <pjammer> if you have 1 primary and 2 secondary boxes, all using the same AWS image for their /data directory; does that quicken up rs.add() for the two secondary boxes? It's been 12 hours at least, i must be doing something wrong.
[15:49:18] <pjammer> both secondaries are in Unknown states.
[15:51:43] <cheeser> it shouldn't take much time at all for replSet updates like that.
[15:53:05] <pjammer> thanks @cheeser i figured but this is the second time i tried as i was too 'anxious' last time and followed the log messages i was getting on the secondaries, turning them into primaries...etc
[15:53:40] <pjammer> rs.add("mycname.com") and wait, right?
[15:53:52] <pjammer> on the initiated Primary box.
[15:54:19] <pjammer> i guess i can remove them and add again and check logs.
[15:55:03] <pjammer> each box i want as a secondary should also be started, and using the replset= in mongo.conf right? docs don't say explicitly that but hint at it.
[15:58:46] <cheeser> using mtools on my local box, i can bring up 3 mongoses, 3 shards with 3 member replSets, and 1 configserv in < 15s
[16:02:11] <pjammer> does /data size matter?
[16:04:05] <mtree> hey, i need to update object selected not by id but by date AND string field, how can i achieve this?
[16:04:32] <mtree> i know i can make an query before and get id of that field, but is there any way to avoid this?
[16:04:37] <mtree> a*
[16:04:58] <mtree> s/field/object
[16:05:05] <StephenLynx> sudomarize that doesn't even use any of mongo implementations.
[16:05:12] <StephenLynx> just stick to the basics and do what you need to.
[16:05:20] <StephenLynx> that example seemed very stupid, IMO
[16:05:31] <StephenLynx> despite coming from 10gen
[16:07:06] <bantonj81> can anyone help me with getting the now discontinued MongoDB EC2 AMI?
[16:12:21] <deathanchor> anyone use tokumx on centos 7? I'm having issues starting it up using systemd. :(
[16:44:42] <EdwardL> hi everyone, I'm seeing high CPU usage across my mongos processes -- about 25% CPU load when I'm running stress tests. The mongos processes are running on our application servers and only handle simple queries (find by id -- yes, it's indexed as well). Is this normal?
[17:14:17] <JokesOnYou77> Hi all. I'm using pymongo (3.0.1) and I'm trying to loop over a cursor and modify each document in it but I keep getting strange errors and nothing I've found on line is helpful. I can't even tell if using $set in the loop is modifying document order in the cursor
[17:19:03] <juliofreitas> OMG, I've a simple question. I'd like to select all values of my field cities. I saw the documentation and there is query just for more complex query such as or, and, gte, lt... For example: select cities from collection
[17:21:12] <StephenLynx> GothAlice is familiar with pymongo
[17:21:22] <StephenLynx> JokesOnYou77
[17:23:41] <cheeser> juliofreitas: and your question is what?
[17:24:31] <juliofreitas> select all cities...
[17:24:34] <JokesOnYou77> GothAlice, Do you have any advice for looping over a cursor and modifying each element with pymongo? A simple for doc in cursor: do stuff... db.collection.update_one(blah blah) has been causing problems for me
[17:24:57] <cheeser> juliofreitas: that's ... not a question...
[17:25:19] <juliofreitas> cheeser, db.myDB.find({cities: "city1"}), I want to select all cities, not just city 1...
[17:25:39] <cheeser> pastebin what your documents look like
[17:34:48] <juliofreitas> cheeser, http://pastebin.com/6rz98uws
[17:35:11] <juliofreitas> Its a stupid question but I know just using and, or, greather than...
[17:36:29] <cheeser> db.myDB.find({}, {"city" : 1})
[17:37:11] <juliofreitas> omg, I'm trying db.myDB.find({"city" : 1})
[17:37:14] <juliofreitas> thank you
[17:38:23] <cheeser> juliofreitas: http://docs.mongodb.org/manual/reference/method/db.collection.find/#projections
[17:39:16] <EdwardL> hey guys, not sure if you had a chance to look at the question i posted about an hour ago (probably got pushed out of everyone's screens)
[17:40:10] <cheeser> never saw it
[17:40:44] <EdwardL> ok i'll just paste it again
[17:40:45] <EdwardL> I'm seeing high CPU usage across my mongos processes -- about 25% CPU load when I'm running stress tests. The mongos processes are running on our application servers and only handle simple queries (find by id -- yes, it's indexed as well). Is this normal?
[17:41:29] <cheeser> dunno about that one
[17:41:46] <EdwardL> happy to answer any clarifying questions if you have any
[17:51:49] <deathanchor> anything in the mongos logs?
[18:12:01] <pjammer> mine is pegged to 8 to 10 according to NR. standalone EdwardL
[18:12:13] <pjammer> fwiw
[18:13:33] <EdwardL> do you have a ballpark of what your queries/sec rate is pjammer?
[18:15:04] <pjammer> mms opscounters vary on writes and reads but no i haven't got that far.
[18:15:24] <pjammer> hoping the universe rewards me for helping out someone on here with my issues.
[18:15:42] <EdwardL> hah. thanks though :)
[18:16:36] <pjammer> what are you pulling bw?
[18:16:39] <pjammer> what are you pulling btw?
[18:17:04] <EdwardL> deathanchor: nothing in the mongos logs
[18:17:12] <EdwardL> about 5k QPS
[18:18:45] <EdwardL> of course, CPU usage is dependent on hardware but it's been consistently around 20-25% across EC2 and bare metal machines
[18:20:06] <StephenLynx> 5 thousand queries per second?
[18:21:03] <EdwardL> yes
[18:21:38] <StephenLynx> I don't think that using 25% of CPU is bad then. are you having issues with performance? have you read from a source that it should be using less?
[18:25:02] <EdwardL> we're not having issues with performance just yet -- we're planning to migrate databases and we noticed mongos eats up quite a bit of CPU... our application servers already use 70% CPU during peak times and so adding another 25% on top of that would not leave a lot of overhead
[18:25:55] <EdwardL> no, i haven't read from another source that it should be any lower, i wanted to see if there was any thing we could do to possibly lower that figure
[18:26:04] <EdwardL> or if we've configured anything incorrectly
[18:26:51] <EdwardL> but we've basically configured our cluster as the docs suggest
[18:27:35] <sudomarize> StephenLynx: the thing is i'm not really sure what the 'basics' are when it comes to a category system in mongo
[18:28:09] <StephenLynx> it isn't advised to keep the db on the same server of the application on heavy applications.
[18:28:30] <StephenLynx> if you had that db by itself on his own machine, then 25% wouldn't be a problem at all.
[18:29:03] <StephenLynx> sudomarize the basics is that there are no foreign keys at all.
[18:29:20] <StephenLynx> you cannot actually relate anything.
[18:29:20] <EdwardL> the DB cluster (shards and replicas) sit on their own machines -- only mongos is sitting on the application machines
[18:29:33] <cheeser> there are FKs. just no RI.
[18:29:47] <StephenLynx> well, conceptually FK's.
[18:29:57] <StephenLynx> there isn't an actual implementation.
[18:30:06] <cheeser> come again?
[18:30:23] <cheeser> http://docs.mongodb.org/manual/reference/database-references/
[18:31:00] <StephenLynx> and the driver only performs additional queries when it encounters dbrefs.
[18:31:23] <sudomarize> StephenLynx: how would you recommend storing my categories? in the actual product Document that has a category you mean?
[18:31:30] <StephenLynx> "To resolve DBRefs, your application must perform additional queries to return the referenced documents. "
[18:31:53] <cheeser> yes. so FKs but no RI.
[18:31:55] <StephenLynx> and will a dbref check if the reference actually exists when recording?
[18:32:01] <cheeser> nope
[18:32:04] <StephenLynx> so
[18:32:08] <cheeser> "no RI"
[18:32:10] <StephenLynx> it is no more than a guideline.
[18:32:17] <StephenLynx> to be resolved by the driver.
[18:32:26] <cheeser> sure. but still an FK.
[18:32:47] <StephenLynx> under a very permissive understanding of FK.
[18:33:24] <cheeser> a key that points to a record external to the current one
[18:33:54] <sudomarize> i don't understand why using those models isn't recommended tbh. Some of them seem like they'd do a good job: http://docs.mongodb.org/manual/tutorial/model-tree-structures/
[18:34:11] <sudomarize> what's the alternative?
[18:35:41] <StephenLynx> I never said its not recommended.
[18:36:22] <StephenLynx> I am just saying there isn't any actual implementation in mongo to make sure you are referencing correctly or that will resolve these references in the db layer.
[18:36:46] <StephenLynx> that example is not an example of mongo doing things, is just a thing you can do with mongo.
[18:38:22] <StephenLynx> learn how to query, how to aggregate, how to project.
[18:38:35] <StephenLynx> then understand how you can use these tools to implement what you need.
[19:16:03] <juliofreitas> cheeser, thank you!!
[19:20:56] <cheeser> juliofreitas: all better?
[19:25:49] <sudomarize> StephenLynx: could i ask what model you would use for this?
[19:26:04] <StephenLynx> I don't know what your requirement is.
[19:26:17] <StephenLynx> you just want to have a category for items?
[19:28:11] <fewknow> sudomarize: without knowing the query pattern or how you wish to update the data it is hard to design a model
[19:28:57] <fewknow> they differ in a lot of ways for mongo...depends on what needs to perform well and what doesnt'...depends on if you need to relate to other objects....
[19:29:04] <fewknow> if you require a 3K insertion rate
[19:32:58] <sudomarize> fewknow: right fair point. the context is i'm working on an app for doing tasks locally, and i want a user to be able to search intelligently for categories. An example category tier would be Home -> Repair -> Flooring, so when a user types say "repair" into the input, it will return a list of categories that are children of the Repair category
[19:33:26] <fewknow> use elastic search
[19:33:27] <fewknow> lol
[19:33:50] <fewknow> so for that
[19:33:56] <fewknow> you have a collection of Categories
[19:34:10] <fewknow> each with 'name', 'type', etc
[19:34:33] <fewknow> have children array
[19:34:44] <fewknow> return that once you match
[19:35:48] <fewknow> then you would have chidren of children...with out an actual relation between the documents
[19:36:21] <sudomarize> fewknow: yeah tried to set that up, was having a bit of trouble so just defaulted to the mongo solution for now.
[19:36:36] <sudomarize> fewknow: what would an example of that look like exactly?
[19:36:58] <fewknow> the document?
[19:36:58] <sudomarize> fewknow: like this? http://docs.mongodb.org/manual/tutorial/model-tree-structures/#model-tree-structures-with-an-array-of-ancestors
[19:37:02] <sudomarize> yeah
[19:37:10] <fewknow> that is not a mongo solution
[19:37:14] <fewknow> that is just an example of how to use mongo
[19:37:34] <fewknow> you can us that
[19:37:38] <fewknow> would look like this
[19:39:32] <StephenLynx> do your objects can have multiple categories or have either a parent or children category in the same field?
[19:39:43] <StephenLynx> if not, I would have multiple fields, for super and sub categories
[19:40:15] <StephenLynx> but I would also have a separate collection for these categories so you could be able to know what you can search.
[19:40:33] <sudomarize> StephenLynx: nope, only one category (this makes sense no?).
[19:40:47] <StephenLynx> ok
[19:40:57] <StephenLynx> but you have several levels of categories, right?
[19:41:16] <sudomarize> StephenLynx: ah ok so in my Task document i'd have a parents and children array, and then i'd also have a Categories collection?
[19:41:24] <StephenLynx> like repair being a super category and flooring a sub category
[19:42:32] <StephenLynx> the object that belongs to a category may have in its category field flooring (subcategory) or it may have repair too?
[19:42:39] <fewknow> sudomarize: something like this
[19:42:40] <fewknow> https://gist.github.com/sflint/d89e562aa6fa22220eda
[19:42:46] <fewknow> not perfect to be honest
[19:42:55] <fewknow> and it is recursive
[19:43:00] <fewknow> but it will do what you want
[19:43:17] <StephenLynx> I don't think a recursive model is good for mongo.
[19:43:26] <fewknow> just queries
[19:43:28] <StephenLynx> because it depends on dynamic relation resolution.
[19:43:39] <StephenLynx> which would require several queries by the application.
[19:43:42] <fewknow> yes
[19:43:44] <fewknow> i agree
[19:43:51] <fewknow> but that is the simple way
[19:44:02] <fewknow> more complicated then the application has to keep everything in sync with parent and child
[19:44:08] <StephenLynx> it doesn't matter if its simple when halts his application to a grind.
[19:44:08] <fewknow> which i like better but more complicated
[19:44:21] <fewknow> that is why i asked query pattern
[19:44:26] <fewknow> how many categories?
[19:44:32] <fewknow> how many children
[19:44:41] <fewknow> i would use elastic for this anyway ... not mongo
[19:45:21] <sudomarize> fewknow: I was going to set up a river
[19:45:52] <sudomarize> also i'm using meteor, not sure if that makes this more difficult or not
[19:46:15] <fewknow> i don't use it
[19:46:18] <StephenLynx> I always recommend sticking to the driver.
[19:46:25] <fewknow> AGREEE ^
[19:46:35] <fewknow> or write your own DAL using the driver
[19:46:37] <StephenLynx> so it won't screw you over or hide things that will eat up performance.
[19:46:42] <fewknow> which is the same
[19:46:57] <fewknow> for prototyping metor, mognoengine, other shit is good
[19:47:01] <fewknow> but for prod you don't want to use it
[19:47:23] <fewknow> you need to have that control....another reason why developers shouldn't be in the data layer
[19:47:27] <fewknow> lol
[19:47:52] <StephenLynx> what I would do in your case: have several fields, each one for a category level. so a document would have supercategory: repair, subcategory: flooring
[19:48:08] <StephenLynx> then I would also pre-aggreate available categories.
[19:48:13] <StephenLynx> in a collection
[19:49:05] <fewknow> or you could use elastic and just insert the document(using log-stash) ....then it automatically is ready to search for cateogories....
[19:50:13] <StephenLynx> I would store each document as the highest-level category and have it containing an array of sub-categories which could also have each its array of subcategories.
[19:51:04] <StephenLynx> this is what you are talking about fewknow?
[19:51:05] <StephenLynx> https://www.elastic.co/
[19:51:17] <fewknow> yeah
[19:51:22] <fewknow> elasticsearch .. sorry
[19:51:23] <sudomarize> I definitely think ES is the way to go, i suppose i just need to figure out the model for my Task collection in that case. so StephenLynx, you suggest each Task document should have {name: "midcategory", parent: "parentcategory", child: "childcategory"}
[19:51:51] <StephenLynx> a task is the object that belongs to a category, right?
[19:51:54] <fewknow> sudomarize: modeling in ES is way differnt than mongo
[19:52:07] <fewknow> ES using the indexes(patitions) to search
[19:52:34] <fewknow> you just need to insert the data into ES the right way.....but that is a different storry
[19:52:51] <sudomarize> StephenLynx: i'm not sure about the terms, but a Task has a category key
[19:53:13] <StephenLynx> yeah, its what you just showed me.
[19:53:22] <sudomarize> yeah
[19:53:28] <sudomarize> fewknow: oh
[19:53:35] <StephenLynx> that is data duplication, but then it makes easy to query.
[19:53:52] <StephenLynx> be it if you are looking for the parent, child or mid category.
[19:55:11] <sudomarize> StephenLynx: is that significantly inefficent enough to choose another method? Sorry for all these questions, but i'm basically new to mongo and to elasticsearch, so trying to implement the best solution is proving quite difficult
[19:55:36] <sudomarize> fewknow: how exactly would i integrate elasticsearch with the search?
[19:55:50] <StephenLynx> no, duplicating that is not much.
[19:56:00] <StephenLynx> you won't waste too much space with that duplication.
[19:56:44] <StephenLynx> and considering you would have to perform several queries to find out what is the super category, I believe that duplication is the best approach.
[19:56:57] <fewknow> sudomarize: what do you mean? ES is restFul .... you POST data and GET data
[19:57:26] <fewknow> issue a GET with the query criteria and get the results
[19:57:27] <StephenLynx> what exactly is ES? It is a cache?
[19:57:56] <fewknow> Its distributed search backed by disk
[19:58:03] <fewknow> it does have a caching layer
[19:58:12] <fewknow> but it is built for searching and it is very very fast at it
[19:58:53] <sudomarize> fewknow: i get that it's REST, just wondering how the data is stored (or perhaps 'in what format' is a better way to phrase that).
[19:59:03] <fewknow> json
[19:59:19] <sudomarize> got ya
[19:59:32] <fewknow> but is has paths /something/something/something
[19:59:47] <fewknow> and that is indexed and every field in the json document is indexed
[19:59:54] <fewknow> index in ES is not a traditional index
[19:59:58] <StephenLynx> I still don't get how would one use that in combination of mongo.
[20:00:06] <StephenLynx> wouldn't it replace mongo?
[20:00:10] <fewknow> yes
[20:00:12] <fewknow> sorry
[20:00:21] <StephenLynx> ah.
[20:00:22] <fewknow> would use that for search out side of mongo sompleely
[20:00:25] <fewknow> completely
[20:00:29] <sudomarize> my understanding was that i would need to set up a stream from the meteor mongodb, and then you can search ES independtly of mongo (Taking some load off the application)
[20:00:49] <StephenLynx> I would just use mongo.
[20:01:02] <StephenLynx> you problem is not complicated.
[20:01:24] <StephenLynx> even though it is very relational, it can be solved with a little duplication and pre-aggregation.
[20:01:43] <StephenLynx> if you stick to a fixed maximum depth in your categories.
[20:03:11] <StephenLynx> just keep in mind that it won't be a very flexible solution.
[20:03:36] <StephenLynx> if one day the shithead decides he want's recursive categories, it won't do.
[20:04:49] <sudomarize> StephenLynx: what do you mean by recursive categories?
[20:05:34] <StephenLynx> the object that belongs to a category has just one category that may be n levels deep in category hierarchy.
[20:06:09] <sudomarize> StephenLynx: and which doesn't have all the duplication?
[20:06:41] <StephenLynx> no, but is pretty much unmaintainable and would require several queries to resolve depending on your requirements.
[20:07:11] <StephenLynx> I would use a relational database if flexibility is a concern.
[20:08:31] <sudomarize> StephenLynx: unfortunately i cant, until meteor implement the drivers
[20:08:44] <StephenLynx> I don't even know what meteor is.
[20:08:54] <StephenLynx> But I have a hunch is one of the things I would never use.
[20:08:55] <sudomarize> StephenLynx: reactive fullstack javascript framework
[20:08:59] <StephenLynx> PFFFF
[20:09:00] <StephenLynx> HAHAHAHAA
[20:09:03] <StephenLynx> yeah
[20:09:31] <StephenLynx> aside from "javascript" it has all the magic words that would make me kill it in a fire.
[20:09:43] <sudomarize> lol
[20:09:59] <StephenLynx> want me to go in details?
[20:10:03] <sudomarize> please
[20:10:06] <StephenLynx> ok
[20:10:07] <StephenLynx> first:
[20:10:11] <StephenLynx> reactive.
[20:10:35] <StephenLynx> it is just performing http requests.
[20:10:39] <StephenLynx> theres nothing special there.
[20:10:59] <StephenLynx> you are just adding bloat and losing flexibility.
[20:11:05] <StephenLynx> second: fullstack
[20:11:25] <StephenLynx> it is just bundling a bunch of unrelated stuff, again it may add bloat and removes flexibility.
[20:11:52] <StephenLynx> then framework: it is just doing every day things that already provides a high-level interface for development, so its just bloat.
[20:12:24] <StephenLynx> you are using node or io, since its "fullstack js", right?
[20:12:37] <sudomarize> StephenLynx: correct
[20:12:45] <StephenLynx> I have been using nothing but io.js and the node.js driver, you really don't need anything else.
[20:13:17] <StephenLynx> http://gitlab.com/mrseth/bck_lynxhub
[20:13:38] <StephenLynx> I have a smaller project in the same style too.
[20:13:48] <sudomarize> honestly ideally i would be using those, but the development speed that meteor provides is (thus far) well worth the bloat
[20:14:14] <StephenLynx> that is actually a parroted lie.
[20:14:55] <sudomarize> that development speed is faster in meteor?
[20:15:02] <StephenLynx> addings things that don't do anything that couldn't be already done only increases the learning curve and add sources of problems.
[20:15:16] <StephenLynx> anything that it does could be done with small pieces of reusable code.
[20:15:59] <StephenLynx> after these pieces of reusable code are written, you just have to bother with business logic.
[20:17:20] <StephenLynx> in any term you are just losing time.
[20:17:44] <StephenLynx> unless you are a highly experienced developer in these specific tools and is thinking in the short term.
[20:17:56] <sudomarize> which stack would you personally use for such a project?
[20:18:11] <StephenLynx> the same as I used in the project I linked.
[20:18:19] <StephenLynx> io.js, mongo and its driver.
[20:18:51] <sudomarize> StephenLynx: any framework though?
[20:18:54] <StephenLynx> no.
[20:18:56] <sudomarize> express, for instance?
[20:19:00] <StephenLynx> express is shit.
[20:19:25] <sudomarize> That sounds like a lot of code you need to write
[20:19:26] <StephenLynx> as I said, if a framework only does stuff that could be already done, then its useless.
[20:19:31] <StephenLynx> no, its not.
[20:20:01] <StephenLynx> extending a system is just as easy because you have already written the reusable parts.
[20:20:14] <sudomarize> how do you do routes for instance, using only node? (without writing a large amount of code)
[20:20:33] <StephenLynx> I do that in my smaller project, just a second
[20:21:11] <StephenLynx> https://gitlab.com/mrseth/io-boot
[20:22:00] <StephenLynx> https://gitlab.com/mrseth/io-boot/blob/master/boot.js line 308
[20:22:14] <StephenLynx> I get the url, take it apart and work from there.
[20:22:19] <StephenLynx> its pretty simple.
[20:22:25] <StephenLynx> 6 lines or so.
[20:23:38] <StephenLynx> if people would bother to actually try and work without these frameworks, they would see how much they don't need them.
[20:24:44] <StephenLynx> in 3 lines I already have the path I want.
[20:25:25] <StephenLynx> in 6 the specific resource in that path.
[20:26:15] <StephenLynx> 5 if you take in account that one line is used for some unrelated business.
[20:26:36] <StephenLynx> that is getting the path in the disk of what I want.
[20:27:33] <StephenLynx> and I really suggest you migrate to io.js. Is a much better fork of node.
[20:28:21] <sudomarize> StephenLynx: im certainly not as skilled a programmer as you are, i imagine doing all this myself would take me forever
[20:28:30] <StephenLynx> 6 lines.
[20:28:47] <StephenLynx> it would not take forever.
[21:12:56] <Vitium> StevePotayTeo, Why use Io.js?
[21:13:13] <Vitium> Wat.
[21:13:20] <Vitium> Wrong person.
[21:48:26] <morenoh149> can I match all or do a passthrough in an aggregation?
[21:49:31] <abishek> is there a way to log all the queries being executed in mongo?
[21:49:45] <abishek> is there a way to log all the queries being executed in mongo for debugging?
[21:49:55] <morenoh149> isnt it in the logs
[21:50:16] <abishek> morenoh149, which logs are you referring to?
[21:51:30] <morenoh149> http://docs.mongodb.org/ecosystem/use-cases/storing-log-data/
[22:04:04] <daidoji> Mongo seems to eat up all my disk space beyond the data sizes of the underlying databases
[22:04:23] <daidoji> like if I insert and drop a lot
[22:04:25] <daidoji> is this normal?
[22:04:31] <daidoji> should I be doing something in my setup?
[22:04:52] <daidoji> like do people mongorepair every downtime or something?
[22:12:19] <daidoji> oh I guess I should have been doing this? http://blog.mongolab.com/2014/01/managing-disk-space-in-mongodb/
[22:29:06] <abishek> is there a good way to generate a time series in mongo db?
[22:29:52] <abishek> right now I am doing a group by date and I am generating the missing timelines on the application server.
[22:57:21] <daidoji> abishek: keep everything in epoch time in Mongo and treat it like an integer. The tooling doesn't really play well with Date() objects.
[22:57:48] <daidoji> abishek: as for generating a time series, shouldn't you just do that in Javascript or whatever language you're using to access Mongo?
[22:58:23] <abishek> yes, that is what I am doing, but it is a bit slow when the datetime range is large
[22:58:49] <abishek> just trying to see if I can do that in Mongo
[22:59:13] <abishek> I am doing a similar stuff in MySQL but I solved it using calendar tables
[23:01:05] <abishek> that problem that I need to solve is, if I am generating the time series by hour, and if a particular hour is missing on the grouped data, then I need to set that hour as 0. am not quite sure on how to do that when using mongo
[23:01:14] <abishek> not sure if this can be acheived using reduce
[23:03:35] <daidoji> oh, generate some collection like "y: <year>, m: <month>, d: <day>, hour: <hour>"
[23:03:46] <daidoji> then do one of those map map reduce patterns to join to your data set
[23:03:53] <daidoji> like you'd do with other joins in mongo
[23:04:20] <daidoji> alternatively, your chosen programming language should let you define some such sequence similarly and just aggregate in your application
[23:05:25] <abishek> on a map reduce can I retrieve data from another collection? could you give me an example?
[23:05:46] <abishek> or atleast how to query the data
[23:08:42] <daidoji> what do you mean? An example of a map/reduce join?
[23:08:51] <abishek> from a simple googling, i understand that this might not work in a sharaded env
[23:09:18] <abishek> i meant, how to access another collection from within a reduce function. is this possible?
[23:09:18] <daidoji> well Mongo is aggressively against joins
[23:09:23] <daidoji> abishek: no
[23:09:32] <abishek> ok
[23:10:13] <daidoji> you map/reduce(coll1)-> res; map/reduce(coll2)->res; reduce(res)
[23:10:29] <daidoji> (although the last one is a m/r but you just use the identity map)
[23:11:43] <abishek> what is the last step that you mentioned `reduce(res)`. is this on mongo or on my app server ?
[23:11:56] <daidoji> abishek: well here. http://tebros.com/2011/07/using-mongodb-mapreduce-to-join-2-collections/
[23:12:13] <daidoji> if you want to have a mongo only solution you can "join" two collections using some form of this pattern
[23:12:23] <daidoji> abishek: but its easier if you just do all this in the app
[23:12:50] <daidoji> imo, its usually much easier to do all the aggregations/calculations in your app than muck around with Mongo Agg framework or map/reduce
[23:12:52] <abishek> yes, its pretty easy except for the performance issue that I am having and I am trying to see if this can be solved from within the DB
[23:13:20] <daidoji> abishek: well then best bet will be to denormalize or make your collection data the right shape for whatever calculations you're trying to perform
[23:13:39] <abishek> yes, I am keeping that as an option as well
[23:13:44] <daidoji> imo map/reduce or agg framework aren't very powerful tools for doing stuff like that
[23:14:40] <abishek> ok