PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Thursday the 25th of February, 2016

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:11:07] <bros> What is a good value for slowMs? 20?
[00:18:24] <cheeser> 100 i think is the default
[00:19:56] <bros> I see that. Some article I read said 20ms. Is that a little extreme?
[00:20:25] <cheeser> probably so
[00:30:44] <bros> Do I write schemas.account.index({ '_id': 1, 'users._id': 1 }); or schemas.account.index({ 'users._id': 1 });
[00:37:23] <bros> The order of the fields does not matter, right?
[03:11:12] <hendry> hi there, are there tools to help migrate from GAE datastore to MongoDB?
[06:56:44] <fandi> hi all
[06:56:51] <fandi> i need to configure
[06:57:17] <fandi> cluster mongodb
[07:01:56] <fandi> my version mongo is 3.2.3, when i put replSet on /etc/mongod.conf .. and try start
[07:55:20] <shortCircuit__> hi, I need some help with mongodb querying
[08:23:03] <mylord> is this right? db.users.find({"points":/.*2016*/})
[08:23:16] <mylord> to find points:”2016-2-25” for example?
[08:23:19] <mylord> it’s not finding
[08:24:06] <shortCircuit__> i think there should be $match
[08:24:30] <shortCircuit__> or a $regex
[08:25:16] <shortCircuit__> db.users.find({ points: { $regex: /2016-*/$ }}) maybe
[08:25:35] <mylord> Invalid flags supplied to RegExp constructor '$'
[08:25:35] <shortCircuit__> .* isn't good .. induces backtracking
[08:25:41] <mylord> so how?
[08:26:24] <shortCircuit__> oh its the problem with the /$ in the end ..
[08:26:48] <partycoder> if you do it at scale you will kill your db
[08:27:22] <shortCircuit__> put the $ inside the /
[08:27:53] <shortCircuit__> yeah regex is murky waters .. :P
[08:28:51] <mylord> so.. how do we search MongoDB records for %LIKE%?
[09:00:07] <ramnes> mylord: LIKE is evil
[09:54:07] <Ameo> are setting indexes on collections worth doing from a performance standpoint?
[10:09:48] <partycoder> yes
[10:10:22] <partycoder> however you won't notice it on a small collection
[10:10:45] <partycoder> you can use "explain" to get the execution plan for a query
[10:15:04] <mylord> how to I use update to only update fields I provide, and not replace whole object?
[10:15:32] <mylord> Must I use $set on an array of fields? Or some nicer way?
[10:18:57] <Derick> you need to use $set : { field1: value, feidl2: value }
[10:54:44] <Lope> any ideas what happened to the other find params, such as projection? http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#find
[11:12:34] <Boomtime> @Lope: the url you gives shows a projection in the third example
[11:14:20] <Lope> Boomtime: thanks, sorry I forgot to say I saw that. I was a bit confused because I was previously using the mongojs implementation.
[11:48:11] <jhalliday> https://jira.mongodb.org/browse/HADOOP-143 - anyone know why this is marked fixed even though it isn't?
[11:58:18] <kurushiyama> jhalliday: You updated accordingly?
[12:22:16] <cheeser> it was marked fixed because it was believed to be fixed. if you're finding that's not the case, please file a new ticket.
[14:19:50] <Fadey> hello
[14:20:11] <Fadey> I need some help with mongodb setup I made on Centos 7
[14:20:21] <Fadey> Can someone help me with it?
[14:22:33] <cheeser> only if you state the actual problem. right now all anyone can do is guess. so save everyone some time and explain the problem. if someone knows a solution, perhaps they'll speak up.
[14:26:38] <Fadey> okay np
[14:26:59] <Fadey> So I've Installed mongodb v2.6.11 on centos 7 machine (AWS)
[14:27:52] <Fadey> I have an old data (huge) from another machine (centos 6.4) so I took it's disk and attached it to the centos 7 machine
[14:28:02] <Fadey> mounted it to /mnt/snapshot
[14:28:17] <Fadey> stopped mongo
[14:28:23] <Fadey> did ln -s /mnt/snapshot/var/lib/mongo /var/lib/mongo
[14:28:42] <Fadey> and ran mongo as a service again ( service mongod start)
[14:28:48] <Fadey> got this output to the log:
[14:29:03] <Fadey> 2016-02-25T14:08:44.200+0000 [initandlisten] exception in initAndListen std::exception: boost::filesystem::status: Permission denied: "/var/lib/mongo", terminating
[14:29:32] <Fadey> I tried everything I know with the permissions.. I don't know what else I can do
[14:39:03] <Fadey> you can find my question also on stackoverflow: http://stackoverflow.com/questions/35630148/mongodb-2-6-11-wont-start-after-changing-dbpath-centos-7
[14:40:03] <jhalliday> sure it's perms rather than selinux labels?
[14:41:01] <cheeser> can you copy that data over rather than use it off the mounted drive?
[14:43:19] <Fadey> I could copy but it will take tons of time
[14:43:35] <Fadey> Im not sure it's not a selinux labels
[14:43:39] <cheeser> well, you're not getting anything done now... :)
[14:43:57] <Fadey> I dont even know how to handle selinux
[14:44:35] <Fadey> cheeser that's true :) but that's a poc for like 20 machines that needs to migrate
[14:45:18] <Fadey> I'd rather leave the data outside the root drive and have it ready to mount
[14:47:39] <foxnesn> i have a record local:{email:"blah@blah.com",password:"123456"} how on earth do i do a findOne for it?
[14:47:48] <foxnesn> i tried local.email
[14:48:26] <foxnesn> and local:{email:"blah@blah.com"} returns null
[14:49:16] <foxnesn> w nevermind i need local.email in double quotes
[14:49:20] <foxnesn> ...
[15:11:44] <Fadey> okay found the issue
[15:11:52] <Fadey> it was the selinux indeed
[15:12:00] <Fadey> did [root@ip-10-0-0-149 lib]# setenforce 0 [root@ip-10-0-0-149 lib]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy vers
[15:12:14] <Fadey> solved the problem
[15:17:58] <Fadey> thank you
[18:37:14] <Trinity> can someone explain how a node.js mongodb driver could get sql injected?
[18:37:27] <Trinity> i've tried a couple of experiments but haven't been able to inject operators into my own code
[18:40:03] <StephenLynx> well
[18:40:06] <StephenLynx> it can get injected
[18:40:09] <StephenLynx> just not a sql injection.
[18:40:19] <Trinity> StephenLynx, what should I be worried about primarily?
[18:40:38] <StephenLynx> taking json data and not making sure they are the type they should be.
[18:40:39] <StephenLynx> for example
[18:40:48] <StephenLynx> you are looking for an account with credentials X
[18:40:50] <kurushiyama> Trinity: basically it is the same story as Bobby Tables.
[18:40:56] <StephenLynx> no
[18:40:59] <StephenLynx> is different
[18:41:15] <StephenLynx> lets say you want an account that matches the login and token you are receiving
[18:41:16] <StephenLynx> HOWEVER
[18:41:30] <StephenLynx> you just use a simple {login:param.login, token: param.token}
[18:42:09] <StephenLynx> and then if, lets say, token is not a string, but an object with an operator that will always match or just be discarded
[18:42:21] <StephenLynx> then it won't be taken in account and all it will take is the login to match.
[18:42:46] <StephenLynx> a value for token that would make it inject is {$ne:null}
[18:42:52] <StephenLynx> it will match all documents
[18:43:24] <StephenLynx> so now all the attacker has to know is the login of an account he wishes to be granted authorization.
[18:43:53] <StephenLynx> how to prevent? param.token = param.token ? param.token.toString() : '';
[18:43:54] <Trinity> StephenLynx, right I got that far
[18:44:11] <Trinity> let me see if I can find my test scenario
[18:44:21] <Trinity> and you can point out what i'm doing wrong
[18:45:06] <Trinity> StephenLynx, http://pastebin.com/AAvB2UCV
[18:45:38] <kurushiyama> StephenLynx: Which – correct me if I am wrong here, too – input sanitation?
[18:46:00] <Trinity> ah, if input is not a string
[18:46:07] <Trinity> but I still don't see how it could be done with an object
[18:46:22] <StephenLynx> {$ne:null}
[18:46:37] <Trinity> ah I see
[18:46:50] <Trinity> so is this the only case scenario? or are there other vectors to be aware of as well>?
[18:47:00] <Trinity> I usually do a typeof variable === 'string' check
[18:47:19] <StephenLynx> thats also valid.
[18:47:37] <Trinity> ? it's possible to inject with just a string?
[18:47:40] <StephenLynx> no.
[18:48:00] <StephenLynx> because mongo queries are not strings
[18:48:07] <StephenLynx> so no matter what is in that string, it won't change a thing.
[18:49:30] <Trinity> okay, so make sure input is not an object and that's it? of course also testing for acceptable characters would be even better but is there anything else to be aware of?
[18:49:45] <StephenLynx> no need to bother with specific characters.
[18:50:14] <StephenLynx> and yeah, pretty much if the input is not an object, it won't be able to cause anything.
[18:50:28] <StephenLynx> it will either match or not.
[18:50:47] <Trinity> okay, great. I think I understand it better now. Thanks StephenLynx :)
[18:50:51] <StephenLynx> np
[19:32:23] <diggitydane> I'm signing up users through passport and I want them to only edit their own resources/documents. Is adding a user to the document and then always finding by document._id and user._id the right way to do this? I'm new to mongo, and it feels very RDB, but not sure how else to do it
[19:35:15] <foxnesn> diggitydane i am in a similiar boat coming from oracle
[19:35:24] <foxnesn> trying to learn mongo best practice
[19:36:07] <foxnesn> like if i have a users collection which contains email and a products collection how can i relate them?
[19:36:19] <foxnesn> i guess mongo 3.2 has the abilty to "join" collections
[19:37:44] <diggitydane> foxnesn, yeah, I can't find any good examples for users only editing their stuff. All the searches I do reference the mongo Users and Roles, which appears different than "end users"
[19:38:58] <diggitydane> I made a UserSchema, and then in the document I do: user: { type: ObjectId, ref: 'UserSchema' }. So it allows me to find anything by that user._id, but again, not sure if that's the right way
[19:39:17] <StephenLynx> show me your model.
[19:41:22] <StephenLynx> dbrefs are resolved at a driver level
[19:41:29] <StephenLynx> so don't go trigger happy on them.
[19:41:33] <StephenLynx> they are no replacement for a RDB
[19:42:49] <diggitydane> (If it matters, I'm using node, express, mongoose) https://gist.github.com/anonymous/90077844b450f4e2fed2
[19:43:14] <StephenLynx> express and mongoose are garbage.
[19:43:21] <StephenLynx> I strongly suggest you to not use them.
[19:43:26] <StephenLynx> specially mongoose.
[19:43:39] <StephenLynx> its slow, bugged and doesn't behave properly.
[19:43:43] <diggitydane> what do you use in it's place?
[19:43:47] <StephenLynx> mongodb
[19:43:57] <StephenLynx> its the name of the 1st party node driver.
[19:44:08] <StephenLynx> mongodb.github.io/node-mongodb-native/2.1/api/
[19:44:16] <StephenLynx> and this is its docs.
[19:46:32] <StephenLynx> the biggest issue with mongoose is that is tries too hard to deny the non-relational nature of mongo
[19:46:49] <StephenLynx> so it ended up being nearly 6x slower than mongo because of all the hacks it has to do
[19:47:03] <StephenLynx> not to mention it applies a OOP surface on a procedural driver.
[19:49:45] <diggitydane> sweet, I'll check that out. so is the reference to user appropriate or is that not the mongo way?
[19:49:59] <StephenLynx> not the mongo way at all.
[19:50:07] <StephenLynx> it isn't resolved at a db level.
[19:50:16] <StephenLynx> its just syntactic sugar.
[19:50:35] <StephenLynx> all it does is to query both collections and perform a join on your application.
[19:50:47] <StephenLynx> show me your model.
[19:51:01] <diggitydane> The gist is about 15 lines up
[19:51:18] <diggitydane> https://gist.github.com/anonymous/90077844b450f4e2fed2
[19:52:05] <diggitydane> so how do you only pull a users documents and not allow them to edit others documents? I'm having a disconnect there and can't find a good resource that explains it
[19:52:06] <StephenLynx> so is it just a 1-1 relation?
[19:52:33] <diggitydane> 1 to many. a user could add many recipes
[19:52:46] <StephenLynx> then why not have an embedded array on the user?
[19:53:16] <StephenLynx> containing all of its recipes?
[19:53:26] <StephenLynx> and your model doesn't describe the recipes.
[19:53:58] <StephenLynx> all I can see is the relation between the user and the social media data.
[19:54:07] <StephenLynx> and even then I don't get it because its just a mongoose definition
[19:54:16] <diggitydane> yeah, I'm not adding a reference of recipes to user.
[19:54:23] <StephenLynx> then
[19:54:28] <diggitydane> the user info is just coming from facebook, and I want them to login and add recipes
[19:54:29] <StephenLynx> where does recipes fit?
[19:54:53] <StephenLynx> if your recipes are not on your database
[19:55:02] <StephenLynx> then is not a database issue you are having.
[19:55:15] <foxnesn> what is wrong with express? it is just a framework
[19:55:24] <StephenLynx> slow, bugged.
[19:55:38] <foxnesn> compared to what?
[19:55:44] <StephenLynx> all web frameworks are awful by design, but express takes the cake, since it has been abandoned.
[19:55:59] <foxnesn> i thought express was just updated
[19:56:09] <StephenLynx> the dude that started moved to another project.
[19:56:16] <foxnesn> well that happens all the time
[19:56:33] <StephenLynx> you are still trashing your performance for nothing using a framework.
[19:56:48] <foxnesn> well not for nothing personally since i am just starting out
[19:56:48] <StephenLynx> express wastes at least 20% of your performance.
[19:57:03] <StephenLynx> especially if you are starting out you shouldn't be using frameworks.
[19:57:17] <StephenLynx> its like operating a chainsaw before learning how to use the manual saw.
[19:57:17] <foxnesn> who says?
[19:57:23] <StephenLynx> my experience.
[19:57:30] <diggitydane> a user can add many recipes. guess I'm not sure what the question is. I'm using the user ref in recipes to know who added what. So, mongo way would be add all recipes into user document?
[19:57:39] <StephenLynx> when you use web frameworks, the actual runtime environment becomes a black box.
[19:57:59] <StephenLynx> you are on auto pilot and won't be able to dodge a crash when you try to land that plane.
[19:58:19] <StephenLynx> diggitydane, your recipes are not on that model.
[19:58:22] <StephenLynx> that is my question
[19:58:27] <StephenLynx> I have no idea what they mean because of that.
[19:58:40] <diggitydane> recipes are their own collection, users are their own collection
[19:58:51] <foxnesn> meh ill take the 20% overhead if it means getting an app up faster
[19:58:55] <StephenLynx> ok, then where is that part of the model?
[19:59:18] <StephenLynx> foxnesn, and thats what separates the code monkeys from the valuable developers.
[19:59:19] <foxnesn> that's what vertical scaling is for
[19:59:27] <StephenLynx> >just throw more hardware
[19:59:29] <StephenLynx> classic.
[19:59:58] <foxnesn> yup
[20:00:56] <diggitydane> which model? and I guess to clear confusion, what are you referring to when you say model? recipe model? It's defined in RecipeSchema in the first snippet
[20:01:24] <StephenLynx> https://gitgud.io/LynxChan/LynxChan/blob/master/doc/Model.txt
[20:01:25] <StephenLynx> this
[20:01:29] <StephenLynx> model documentation.
[20:01:47] <StephenLynx> how is your data organized? what are its constraints? what does each part of your data means?
[20:02:43] <StephenLynx> what you showed me doesn't even explain the collection you are asking how to organize.
[20:03:57] <diggitydane> hmm, that's all there is. recipe has name, description, tags (array) and "foreign key" to user. User is facebook info used by passport. that's it. I'm assuming the mongo model definition is close to the mongoose schema definition.
[20:04:10] <diggitydane> was that model.txt file generated, or someone wrote it out?
[20:04:16] <StephenLynx> manually defined.
[20:04:29] <StephenLynx> documentation driven development.
[20:04:47] <StephenLynx> if recipe has those rules, then give me something laying them out.
[20:08:04] <diggitydane> here is what they look like in mongo console
[20:08:06] <diggitydane> https://gist.github.com/anonymous/5dd8e99cbd5e283fbde6
[20:08:32] <StephenLynx> can you do that again with pretty()?
[20:08:41] <StephenLynx> reading non-formatted json is a royal pain
[20:08:57] <diggitydane> yep, one sec
[20:10:24] <diggitydane> https://gist.github.com/anonymous/6872a75113f69f559362
[20:11:29] <StephenLynx> what does __v means?
[20:11:42] <diggitydane> version
[20:11:48] <StephenLynx> and you could have just an array of recipes on the user document.
[20:12:19] <StephenLynx> and the facebook information could be flat.
[20:12:41] <StephenLynx> that object there serves no practical purpose.
[20:13:23] <foxnesn> not unless he adds more auth strategies
[20:13:39] <diggitydane> I guess that's my question. I'm just trying to build something simple that I can wrap my head around mongo. Is it better embeded in user, or it's own with a relation? From here, I'm going to add ingredients to a recipe. Is that it's own model, or is that embeded in a recipe as an array, etc.
[20:14:19] <foxnesn> you mean its own document?
[20:14:21] <StephenLynx> changes nothing to have more auth methods.
[20:14:28] <StephenLynx> facebookEmail, twitterEmail
[20:14:36] <StephenLynx> just prefix the origin of the data.
[20:14:47] <diggitydane> yeah, own document
[20:14:57] <StephenLynx> wait, ingredients to recipes?
[20:15:01] <StephenLynx> hm
[20:15:08] <StephenLynx> if your recipes are going to become complex
[20:15:17] <StephenLynx> then you might have separate documents.
[20:15:30] <StephenLynx> because complex objects on embedded arrays can become hard to work with.
[20:15:32] <diggitydane> yeah, would that just be added into recipes or it's own collection. then I want to search, and give me all recipes that have chicken
[20:15:45] <StephenLynx> and you lose some features from embedded arrays.
[20:16:09] <StephenLynx> if your embedded array elements are going to have more embedded arrays, then you might as well keep them on separate documents.
[20:16:24] <diggitydane> yeah, I'm trying to figure out where the trade off's are
[20:17:23] <diggitydane> users have recipes, recipes have ingredients. should I have users collection, recipes collection, and ingredients collection? user case scenario would be, what recipes have ingredients X?
[20:17:34] <foxnesn> diggitydane how do you relate your recipes and ingredients docs?
[20:17:58] <StephenLynx> i suggest you just keep users and recipes
[20:18:13] <StephenLynx> how complex do you plan to have recipes?
[20:18:42] <StephenLynx> what do you plan to put on "tags"?
[20:18:53] <StephenLynx> this is why you lay out documentation for the model.
[20:18:59] <diggitydane> foxnesn, I'm just playing with the ingredients now. trying it as embeded in recipes, and then as it's own collection
[20:19:10] <foxnesn> oh i see
[20:19:18] <StephenLynx> if tags are just strings, then keep tags embedded on recipes.
[20:19:56] <foxnesn> i thought the whole point of document oriented database was to not relate things
[20:20:02] <diggitydane> foxnesn, it just feels like everything I'm trying is "relational" in nature, so I'm assuming I'm doing it incorrectly for mongo :) but trying to learn how to do it without
[20:20:06] <StephenLynx> nope.
[20:20:08] <foxnesn> just have one massive flat document with embedded arrays
[20:20:10] <StephenLynx> that isn't the point ,fox
[20:20:32] <StephenLynx> it gets to a point where its worth to have relations because the embedded data is too complex.
[20:20:38] <StephenLynx> and you are duplicating too much data.
[20:20:47] <foxnesn> yes that makes sense to me
[20:20:52] <StephenLynx> document oriented dbs are about flexibility.
[20:21:09] <StephenLynx> you can embed, you can relate and its all about context.
[20:21:19] <StephenLynx> sure, theres a point where its better to just use a different db.
[20:21:27] <StephenLynx> but you have a certain degree of freedom.
[20:25:02] <diggitydane> so, in this case, is it appropriate to have the user ref on recipes, and then when I'm interacting with mongo add in user like .... db.recipes.find({ _id: ObjectId('56cf53a63fa3c061115f01d4'), user: ObjectId('56cc9a28cc22244c05f9b7f3') })
[20:25:22] <StephenLynx> why look for both the _id and user?
[20:25:44] <StephenLynx> if you are looking for the _id, the user is pointless, _id is unique.
[20:26:00] <diggitydane> otherwise, on angular app that uses a resource like ('/api/recipes/:recipeId'), someone can just type in the id and edit it
[20:26:13] <StephenLynx> don't couple the FE into this.
[20:26:30] <diggitydane> how do you restrict a user to their own documents then?
[20:26:36] <StephenLynx> you just do.
[20:26:37] <diggitydane> FE aside
[20:26:41] <diggitydane> by what means?
[20:26:48] <StephenLynx> you know the recipe belongs to a certain user, right?
[20:26:58] <StephenLynx> you know which user is conducting the operation, right?
[20:27:16] <StephenLynx> so just prevent unauthorized interactions on application code.
[20:27:36] <StephenLynx> if recipe.user != user._id = nope
[20:28:07] <diggitydane> exactly, so when you query for the id of the recipe, how do you know the owner?
[20:28:21] <StephenLynx> i don't know, how users authenticate on your system?
[20:28:27] <diggitydane> passport
[20:28:29] <diggitydane> through facebook
[20:28:32] <StephenLynx> then use that.
[20:28:48] <StephenLynx> before anything, fetch the user document
[20:28:55] <StephenLynx> and use it where needed.
[20:29:08] <diggitydane> I am using that. that's how I get the user._id when I query the recipes.
[20:29:22] <StephenLynx> then use it too on updates.
[20:29:40] <StephenLynx> you can study that project I linked.
[20:29:57] <StephenLynx> src/be/engine/accountOps and look for exports.validate
[20:30:17] <StephenLynx> then look at how that is used across the system
[20:30:45] <StephenLynx> any operation that requires authentication uses that and uses the obtained user to perform authorization
[20:31:10] <diggitydane> ok, I'll check it out
[21:01:17] <bros> I have a really weird bug where MongoDB 3.2 isn't "ANDing" the query fields together for a subdocument.
[21:02:07] <bros> db.items.find({ 'listings.store_id': ObjectId("56560297e4ee9436592ce4a6"), 'listings.item_id': '2583', 'listings.variant_id': null }) returns https://gist.github.com/brandonros/543aec4c0f1bf2349d16
[21:02:28] <bros> But as you can see, the first and second documents do not match
[21:08:06] <kurushiyama> bros: They each have one element that matches, right?
[21:08:17] <bros> Yes. I should be using elemMatch instead?
[21:08:59] <kurushiyama> bros: We have a winner! ;)
[21:09:18] <bros> haha It scared me. I've been using MongoDB way too long not to know that.
[21:09:28] <bros> Wonder what other wonderful mistakes I've been making in the past.
[21:10:00] <kurushiyama> bros: Everybody does. As long as you learn from them. I did Java for half a decade ;)
[22:01:35] <Doyle> Hey. if you use noCursorTimeout, do you have to manually kill a cursor somehow?
[22:04:57] <Doyle> nm, I read the manual
[22:16:24] <bros> E11000 duplicate key error index: db.items.$listings.variant_id_1_listings.item_id_1_listings.store_id_1 dup key: { : null, : null, : null }
[22:16:27] <bros> Yet db.items.find({ 'listings.variant_id': null, 'listings.item_id': null, 'listings.store_id': null }) yields 0 results.
[22:18:58] <bros> Is this not supported, or do I just need to use a sparse index?
[22:19:48] <kurushiyama> bros: In general, yes. But keep in mind that for purposes of a unqiue index, non-existing values also are null
[22:20:09] <bros> kurushiyama: Sorry. To clarify, that is, "yes, use a sparse index"?
[22:20:54] <bros> Should I use a partial index instead?
[22:21:30] <kurushiyama> bros: Sorry. Yes, you can use a sparse index. But it heavily depends on your use case. Actually some people insert dummy docs with null values to prevent further null values to be enterd
[22:22:26] <kurushiyama> bros: Albeit I am not sure if an explicit null would trigger the unique constraint anyway...
[22:22:35] <bros> It's actually that the array is empty?
[22:23:29] <kurushiyama> bros: If it is aempty, the corresponding fields of the subdocuments store in the array evaluate to null.
[22:23:44] <bros> Ok. So that is what is causing that error, yes?
[22:23:57] <bros> I am running 3.2. Should I roll a partial index or not even bother?
[22:24:13] <bros> I have server-side checks and don't actually use the constraint, to be honest.
[22:24:23] <bros> I just had to clean up 13k documents to get it to pass.
[22:25:24] <kurushiyama> bros: Well, how should I know? If you dont know your use cases – who does? Instead of a unique index, you might want to give document validation a try. Although I am a big fan of keeping logic where it really belongs to: your code.
[22:25:48] <bros> So you aren't a big fan of unique indexes either?
[22:25:57] <bros> I almost always precede with a .count() to see if it exists anyway.
[22:29:32] <kurushiyama> bros: Unique indices have their uses, of course. Let's take usernames for a webapp, for example. You most likely will check via AJAX while the user types their wanted username. Does a unique index still make sense? Of course, in case somebody tries to bypass you validation logic and simply sends a POST request with a known username and a new password. You are doing an insert on a unique constraint then, causing an e
[22:29:33] <kurushiyama> rror – no harm done.
[22:29:52] <bros> Exactly. I like it as a fallback.
[22:30:25] <kurushiyama> bros: It isnt a good example, but one that sort of pictures it.
[22:30:41] <bros> So, just to murder the dead horse, I'll be fine with a sparse index?
[22:31:17] <kurushiyama> bros: Of the top of my head – I think so, though I am still not sure about explicit null values.
[22:32:05] <kurushiyama> bros: Reading the docs helps. Explicit null values count as values.
[22:32:23] <bros> I'm a bit hazed on how that affects me here.
[22:33:12] <kurushiyama> bros: Well, a partial index might be better here, though admittedly I ahvent worked with them, yet.
[22:33:56] <Hitsnorth> Having some issues setting up authorization in 3.2 its crashing with no message besides Signal 15
[22:35:23] <kurushiyama> Hitsnorth: Ouch.
[22:35:58] <Hitsnorth> security: authorization: "enabled"
[22:36:08] <kurushiyama> Hitsnorth: Wait...
[22:36:30] <kurushiyama> Hitsnorth: You got that "signal 15" from the logs, right?
[22:36:34] <Hitsnorth> Yes from the log
[22:37:03] <kurushiyama> Hitsnorth: And you are absolutely positively sure that MongoDB did not complain about something before that?
[22:37:30] <Hitsnorth> Yes nothing
[22:38:47] <Hitsnorth> If I take that out of the conf it boots up just fine (But of course with no security)
[22:39:33] <kurushiyama> Hitsnorth: Well. I am not really convinced ;) Since you seem to use YAML format: Are you sure you need the quotes? Are you sure you indented correctly?
[22:39:57] <Hitsnorth> Im not sure I need the quotes but thats hwo I saw it (I initially didnt use the quotes).
[22:41:25] <kurushiyama> Hitsnorth: No quotes, space indented should work
[22:41:47] <Hitsnorth> I put 2 spaces it appears to work
[22:44:53] <kurushiyama> Hitsnorth: So problem solved?
[22:45:59] <Spynxic> I'm having a problem grabbing the value of an element in a collection, I use the follow statement to call for the _id value: db.collectionname.containers[index]["_id"] but it returns Collection(Database(MongoClient('localhost', 27017)u'graphs'), u'collectionname.containers.index._id')
[22:46:56] <Spynxic> should mention that it's in pymongo
[22:47:19] <bros> Does this sound right: Profiling is showing that a query I have an index for took 400ms.
[22:47:26] <bros> 30k docs examined
[22:47:30] <bros> 234 yielded
[22:48:41] <Hitsnorth> Not sure its ignoring it if i put 2 spaces in front and authorization is not enabled
[22:53:55] <kurushiyama> Hitsnorth: Check against http://pastebin.com/7adktmjv
[22:55:06] <kurushiyama> bros: If the index exists, you should be able to find it via db.yourcoll.getIndices()
[22:58:34] <kurushiyama> Spynxic: Can you put it to pastebin? Sample doc, query and output?
[22:58:50] <Spynxic> Is there a standard method to printing an array element in pymongo?
[23:00:08] <kurushiyama> Spynxic: Sorry, can't help you with that.
[23:01:08] <Hitsnorth> Kurushiyama I have it like that but no keyfile is that required? When I put that part in it crashes again
[23:01:11] <Hitsnorth> Otherwise its running now
[23:03:27] <kurushiyama> Hitsnorth: Do you have a standalone instance or a replset/sharded cluster? For the former, you don't need it, otherwise: https://docs.mongodb.org/manual/tutorial/enable-internal-authentication/#enable-internal-authentication
[23:04:34] <kurushiyama> Hitsnorth: And it doesnt crash. It shuts down because of misconfiguration ;) YAML – Yet Another Mistake Loop
[23:04:47] <dreamreal> I'm trying to query an object that looks like { "_id":"blah", "foo":"bar", "emails":[{"address":"foo@bar.com"}]} such that I can find that record given foo@bar.com
[23:04:53] <dreamreal> I'm not sure how to form that query
[23:05:58] <bros> key items.item_id must not contain '.'
[23:06:12] <bros> The . is referring to a subdocument, like always? I'm a little lost.
[23:06:59] <dreamreal> $elemMatch did it
[23:06:59] <Hitsnorth> Standalone instaqnce
[23:07:10] <Hitsnorth> Now its working, It doesnt like my password (it has a ! in it )
[23:08:48] <Doyle> Hey. mmapv1 logged index creation, but it seems WT does not. What's the option to set that?
[23:10:57] <kurushiyama> Sorry, was a ghost
[23:11:18] <kurushiyama> Hitsnorth: You should not put the pw on the command line ;)
[23:11:48] <kurushiyama> dreamreal: db.coll.find({"emails.address":"foo@bar.com"}). https://docs.mongodb.org/manual/reference/glossary/#term-dot-notation
[23:14:42] <dreamreal> kurushiyama: I managed with $elemMatch, the dot notation didn't work... although I didn't try it like that. Hmm.
[23:14:49] <dreamreal> Thank you!
[23:15:23] <Hitsnorth> Kuru I didnt I did it in the shell
[23:15:39] <kurushiyama> Hitsnorth: db.auth?
[23:16:15] <Spynxic> Is there a name attributed to the index of an element in an array, for example db.coll.find({"array.key":0}) to find the first element
[23:17:24] <kurushiyama> Hitsnorth: In a lot of environments an exclamation marks has special meanings, so you might want to quote it...
[23:20:03] <kurushiyama> Anyway, g2g.
[23:20:10] <kurushiyama> Good night!
[23:49:54] <Doyle> Index question: When building an index on a sharded collection, should the operation show up on each shard?
[23:50:46] <kurushiyama> Doyle: Aye
[23:50:55] <Hitsnorth> Yes Kuru db.auth, got it working thanks for the help kurushiyama!
[23:51:09] <kurushiyama> Hitsnorth: Np
[23:52:06] <Doyle> kurushiyama, and if it doesn't? db.currentOp( { msg:/Index/ } ) only shows a result against the first shard
[23:52:17] <Doyle> it's very strange
[23:52:23] <Doyle> seems very strange*
[23:54:40] <kurushiyama> Doyle: maybe already finished on the others? Is the shard key involved? Is it a sharded collection, or is it unsharded and the first shard is the rpimary shard of the DB?
[23:55:26] <Spynxic> Are all the contents of a cursor loaded in memory (ram) when its created? (similar to a dict)
[23:56:30] <kurushiyama> Spynxic: Not too sure about pymongo, but usually not. In general, a cursor is a server side iterator.
[23:56:46] <kurushiyama> Spynxic: (simplified).
[23:57:19] <Doyle> kurushiyama, AH, yes! The index operations went sideways on one and pegged the IO on the index volume at 100%, so I killed them and restarted the index creation
[23:57:33] <Doyle> without dropping the index fully, that would make sense
[23:57:37] <Doyle> tyvm
[23:57:58] <kurushiyama> Doyle: yvw