PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Sunday the 3rd of May, 2015

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:56:59] <StephenLynx> project and limit or limit and project?
[00:57:04] <StephenLynx> in aggregation?
[08:03:26] <leporello> Hi. I have a couple of documents with field colors which contains array of colors, contained in image. And I have a filter to choose image containing at least one of that colors.
[08:03:49] <leporello> I think i need $in : colors filter for this, but it doesn't work
[08:04:56] <leporello> colors: { $in: ['red'] } gives me all just red images and colors: { $in: ['red', 'yellow'] }} all red and yellow images.
[08:09:36] <leporello> $in and $all give me same result
[12:15:45] <dimon222_> wait you want images with just ['red']?
[12:15:55] <dimon222_> so they shouldn't contain anything else except of red?
[12:16:19] <dimon222_> actually it was 4 hours ago, nvm ;_;
[15:27:49] <sudomarize> Can i get a hand? What's the best way of implementing a category system (that the user inputs themselves)?
[15:29:11] <sudomarize> i.e. i want my users to be able to select from a list of categories (that is variable), e.g. if they select "repair work" as the 1st, then the next select will have "computers, cars, homes, etc" and when they select one of these, the next set of subcategories will be displayed
[15:32:40] <StephenLynx> pre-aggregated sub categories.
[15:32:48] <StephenLynx> I would have a collection of categories
[15:33:21] <StephenLynx> and each category would have both an array of sub categories
[15:33:32] <StephenLynx> no
[15:33:39] <StephenLynx> that is no good because of the initial fetch
[15:33:52] <StephenLynx> I would have each category a field with its super category
[15:34:07] <StephenLynx> first you fetch all categories missing a super category
[15:34:25] <StephenLynx> then when the user selects a category, you look for all categories that has the selected one as super category
[15:39:17] <sudomarize> StephenLynx: awesome, thanks man
[15:40:58] <StephenLynx> on the objects that actually belong to categories you would have to have an array of categories.
[15:41:15] <StephenLynx> with its immediate category and all its super categories.
[15:41:37] <StephenLynx> and getting the category chain would not be possible, IMO
[15:50:26] <sudomarize> StephenLynx: is another schema necessary in that case?
[15:56:38] <StephenLynx> there is no spoon :v
[15:56:43] <StephenLynx> mongo has no schemas
[15:57:00] <StephenLynx> but of course, you need a collection for categories and for the items that belong to categories.
[16:13:26] <sudomarize> StephenLynx: schema was probaby the wrong word to use there, perhaps 'model' is more accurate
[16:15:39] <sudomarize> the thing is there are all these different possibilites (models) for setting up such a categorization system, and deciding on one that is relatively flexible (i.e. i can add/remove subcategories easily) and is partial to being searched without too much hassle is proving rather difficult
[16:16:22] <StephenLynx> yeah, because you want subcategories. that is a strongly relational characteristic.
[16:16:32] <StephenLynx> and mongo don't implement relations.
[16:20:37] <sudomarize> right, so the best way of emulating this relational nature is just by giving each category a parent field? what about having an array of parent categories?
[16:21:28] <StephenLynx> think about
[16:21:37] <StephenLynx> how you would know the hierarchy
[16:21:53] <StephenLynx> when you change a category, you would have to update all of the arrays
[16:23:52] <sudomarize> StephenLynx: good point...
[16:30:27] <sudomarize> StephenLynx: is there no easy solution to this problem then?
[16:31:19] <StephenLynx> nope.
[16:31:36] <StephenLynx> when you bend a tool's capabilities, there is no easy answer.
[16:34:47] <sudomarize> StephenLynx: couldnt i just run an update when i need to change fields though? wouldn't this only be a problem if i have a huge number of documents?
[16:35:28] <StephenLynx> but then you need to organize in a way you know the hierarchy of the super categories.
[16:35:49] <StephenLynx> when I always consider large amounts of data.
[16:36:05] <StephenLynx> if you want to make something that will run bad on a big scale, do it.
[16:36:11] <StephenLynx> if it works, it works.
[16:36:21] <StephenLynx> it might not just work in the future.
[16:38:27] <sudomarize> StephenLynx: ok, how would you personally go about this, assuming you had to use mongodb? maybe implementing a tags field on my documents and then running a fuzzy search on tags + category? you seem like you've got a deep understanding of mongo, would really appreciate your thoughts
[16:44:02] <StephenLynx> I just told you.
[16:44:16] <StephenLynx> I would have a collection with categories that also holds the super categories
[16:44:40] <StephenLynx> and items would have an array of all the categories in its category hierarchy
[16:44:44] <StephenLynx> sudomarize
[16:46:27] <sudomarize> StephenLynx: alright, i'll implement that. thanks for the advice, appreciate it
[16:46:48] <StephenLynx> btw, it would only hold its immediate super category and it would have just a single super category
[16:49:33] <sudomarize> StephenLynx: oh, as in have a "categories" collection, where the top categories would have {parent: null} and then each subcategory would have {parent:
[16:49:53] <sudomarize> StephenLynx: oh, as in have a "categories" collection, where the top categories would have {parent: null} and then each subcategory would have {parent: "somecategory", ancestors: ["topcategory", "somecategory"]}?
[16:52:01] <StephenLynx> yes
[16:52:14] <StephenLynx> and I would make it simpler
[16:52:26] <StephenLynx> {name:'s', parent:'y'}
[16:53:01] <StephenLynx> so you don't have to worry much about consistency.
[16:53:21] <sudomarize> and just do away with the ancestors array?
[16:53:31] <StephenLynx> yes
[16:53:39] <sudomarize> ok, sweet
[16:54:39] <sudomarize> thanks!
[18:15:24] <fxmulder> so I am cloning one replica to another and after a while the primary machine I am cloning died from lack of memory. Is there a memory leak in 2.4?
[23:47:59] <parallel21> Trying to add a new field to all documents in this db
[23:48:02] <parallel21> Using this command
[23:48:06] <parallel21> db.items.update({},{$set: {"nix": ""}},{multi:true})
[23:48:20] <parallel21> Only the first record is getting updated
[23:50:19] <StephenLynx> no need to add the field.
[23:50:23] <StephenLynx> if its empty.
[23:50:37] <StephenLynx> and that should have worked.
[23:50:43] <parallel21> Hrmm...
[23:52:23] <StephenLynx> http://pastebin.com/iFJNicve
[23:52:28] <StephenLynx> parallel21
[23:53:28] <parallel21> Hrmm...
[23:53:29] <StephenLynx> even when I added an empty string in a field
[23:53:31] <StephenLynx> it still worked.
[23:53:38] <StephenLynx> what version are you using?
[23:54:22] <parallel21> db version v2.0.4
[23:54:43] <parallel21> Upgrade to 3?
[23:57:16] <StephenLynx> yeah
[23:57:19] <StephenLynx> upgrade to 3.
[23:57:36] <StephenLynx> :V