PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Saturday the 7th of May, 2016

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:35:53] <kexmex> hey guys
[00:36:00] <kexmex> in your docker image, how does $MONGO_PORT_27017_TCP_ADDR get set?
[00:37:09] <Boomtime> what do you mean "in your docker image"? is this an image you've downloaded from somewhere? created yourself?
[00:42:26] <kexmex> Boomtime : i was looking at official mongo image on Docker Hub
[00:42:45] <kexmex> i am now guessing that these ENV variables are set by docker itself based on ports that are "LISTEN" in dockerfile
[00:42:46] <kexmex> right?
[00:43:18] <Boomtime> "official" you say.. can you provide the link?
[00:45:21] <Boomtime> here is the entirety of the "official" reference to docker i can find from mongodb: https://docs.mongodb.com/manual/administration/production-notes/#hardware-considerations
[00:45:24] <Boomtime> and i quote:
[00:45:26] <kexmex> https://hub.docker.com/_/mongo/
[00:45:32] <Boomtime> "f you run mongod in a container (e.g. lxc, cgroups, Docker, etc.) that ..."
[00:45:50] <kexmex> official maybe docker official oops )
[00:45:52] <kexmex> 10m+ pullz
[00:45:54] <Boomtime> :D
[00:46:28] <kexmex> just looking at Dockerfile and stuff
[00:46:29] <Boomtime> right, but mongodb has no control over what other people/groups/organizations choose to do with the community build of mongodb - including repackaging it
[00:46:31] <kexmex> pretty wacky stuff
[00:46:44] <kexmex> a bit flimsy feeling
[00:47:00] <Boomtime> and there a lot of them - someone here might still be able to help you, but you'd get a better response probably from a docker forum
[00:47:41] <kexmex> I think this answers my Q
[00:47:42] <kexmex> "Docker links automatically propagate exposed ports of one container as shell variables to another container. In this way, the second container can dynamically adjust network settings upon startup without the need to modify an image nor configurations."
[00:47:42] <kexmex> :)
[00:47:56] <Boomtime> nice
[00:51:17] <kexmex> umm except
[00:51:30] <kexmex> how to get dockers to communicate securely across disparate machines
[00:53:24] <Boomtime> do you need them to?
[00:53:44] <Boomtime> or you mean, get applications within the docker to communicate?
[00:54:29] <Boomtime> docker, being a container, should surely map network ports in so the network works transparently
[00:54:38] <kexmex> Boomtime: well say if i run one docker on machine A and another on machine B
[00:54:54] <kexmex> i guess Linking won't work there?
[00:54:59] <kexmex> probably need same engine?
[00:55:21] <Boomtime> er? why do you need to link them? what are you trying to do?
[00:55:29] <kexmex> some kinda orchestration for multiple engines
[00:55:35] <Boomtime> ah
[00:55:43] <kexmex> Boomtime : well their claim is that you can have like N number of resources which is variable
[00:55:45] <Boomtime> ok, well that would be a very docker specific problem
[00:55:59] <kexmex> and then just run instances of dockers... as many as needed
[00:56:05] <kexmex> i.e.. get more shards up or something
[00:56:10] <kexmex> replicas
[03:22:20] <jasvir> Hi there. Can anyone please help me in GeoNear query for java. I am trying like :
[03:22:22] <jasvir> db.runCommand({geoNear: "near", near: [72, 42], maxDistance: 2, spherical: true });
[03:22:55] <jasvir> but it says illegal start of expression. ';' expected
[03:23:27] <jasvir> can anyone please tell me how to use geaonear query in db.runCommand() ?
[03:37:52] <Boomtime> @jasvir: what you pasted was mongo shell syntax - you'll need to check the java docs to see how to pass that to the java driver
[03:52:59] <jasvir> Boomtime: Unable to find any solution.
[03:56:36] <jasvir> I tried this: http://api.mongodb.com/java/3.2/ . There is runCommand option available
[04:10:50] <Boomtime> jasvir: what you posted is not even remotely valid java syntax, which would be obvious to anyone who knows java - i feel like trying to help you is going to start at the "java 101" level - do you actually know java?
[04:11:33] <Boomtime> if you don't you should either learn java first, or just write shell scripts if you can get away with it
[04:19:30] <jasvir> Boomtime: If I doing something, it's obvious that I know that much java to run queries. It is also understood that I have not directly started working on geonear. If you don't know the answer, it's fine. Don't try to show off or something. I don't need your advice about what to learn and what not to. Checking docs is valid answer to those queries w
[04:19:31] <jasvir> here you know that answer is there in docs. If don't know, don't advice that
[04:22:35] <Boomtime> lol
[04:25:35] <Boomtime> so given you're good to go with java, what you need to do is convert the command into a bson object containing the command at the top-level and the parameters embedded in the same object - basically a straight conversion of the JSON object you pasted
[04:25:38] <Boomtime> start here; http://api.mongodb.com/java/current/org/bson/BasicBSONObject.html
[04:26:33] <Boomtime> that object instance can be given directly to the command method - and you'll get a bsonobject back in the reply, note it's actually cursor but the driver might not know that, you'll need to map it yourself
[04:26:50] <Boomtime> you good?
[04:35:03] <jasvir> -_-
[05:04:37] <Lonesoldier728> Hey guys having difficulty figuring out which is the best way to grab data as a user scrolls further down
[05:05:07] <Lonesoldier728> http://stackoverflow.com/questions/37084646/using-mongodb-to-send-back-paginated-data I included my code there if anyone has an idea how I can go about using offset without receiving duplicates
[05:14:57] <Boomtime> @Lonesoldier728: don't use skip(), it doesn't work the way you hope it does
[05:15:16] <Lonesoldier728> What would be the best way then
[05:15:24] <Lonesoldier728> to paginate it in a way
[05:15:26] <Boomtime> the reason first of all -> https://docs.mongodb.com/manual/reference/method/cursor.skip/
[05:15:35] <Boomtime> "The cursor.skip() method is often expensive because it requires the server to walk from the beginning ..."
[05:15:41] <Boomtime> ok... so the solution
[05:15:49] <Lonesoldier728> Right I understood that do any of the options I specify
[05:15:52] <Boomtime> consider what you know; you have the last item
[05:15:53] <Lonesoldier728> in SO make sense?
[05:15:55] <Boomtime> and you are sorting
[05:15:59] <Lonesoldier728> http://stackoverflow.com/questions/37084646/using-mongodb-to-send-back-paginated-data
[05:16:46] <Boomtime> so why not add predicates that uniquely identify the item to find first (and everything else be "greater" than)? the sort will take care of the rest
[05:16:50] <Lonesoldier728> so instead of offset use the last item as the starting point? B
[05:16:57] <Boomtime> you got it :-)
[05:17:05] <Lonesoldier728> the problem there is that a lot of them are on the same level
[05:17:23] <Boomtime> hence the 'uniquely' requirement
[05:17:25] <Lonesoldier728> so there is no greater or less than - maybe alphabetically
[05:17:36] <Lonesoldier728> plus the view count but two fields for sorting is that an issue?
[05:18:00] <Lonesoldier728> essentially it will sort all the docs based on count then again on alphabetical while keeping the count in tact
[05:18:32] <Boomtime> sort on two fields is fine - it has the same performance requirements - make sure the fields are in the index in the same order to assist
[05:18:35] <Lonesoldier728> Or should I just add another field specifically for cataloging the position of the items and update that catalog every day or so
[05:19:35] <Boomtime> if all else fails, you can always add the _id as the final field to the index and sort on that too - it guarantees a unique starting position
[05:20:14] <Boomtime> but if you can do it without that give that a go first - use what you have as much as possible, every field added costs memory, etc
[05:21:05] <Boomtime> i should write an article on efficient pagination, it comes up often
[05:21:29] <Boomtime> there is a *much* simpler method though, if you can do it; keep the cursor
[05:24:05] <Lonesoldier728> Yeah I saw keeping the cursor, the problem is a person can load up items 10 minutes or even an hour or so later possibly, so the cursor cannot stay open that long
[05:24:37] <Boomtime> no worries, you always have _id
[05:24:53] <Lonesoldier728> but is the _id in order? The one mongodb creates?
[05:25:03] <Boomtime> yes, but that doesn't actually matter
[05:25:19] <Boomtime> what matters is that it is unique
[05:25:30] <Boomtime> you already have a preferred sort order right?
[05:25:40] <Lonesoldier728> How would I sort by the id and the view count like this --- .sort({viewCount: -1, _id: 1})
[05:25:52] <Boomtime> that will do
[05:26:02] <Boomtime> be sure to add those to the index servicing the query
[05:26:18] <Lonesoldier728> I should index the view count?
[05:26:36] <Lonesoldier728> the problem with the view count is that it is always changing so index-ing it will be an issue
[05:26:43] <Boomtime> after any equality predicates, yes
[05:26:55] <Boomtime> why?
[05:27:03] <Boomtime> i mean, why is it a problem to index?
[05:27:20] <Lonesoldier728> That is another reason why duplicates might show up which might be an issue, since by the time a user requests to load more the viewCount could have gone up a few positioning it differently in the sort
[05:27:34] <Boomtime> yes, but that would be the correct result yes?
[05:28:07] <Boomtime> unless you save a snapshot of the database at the time they make the first request, you cannot possibly preserve the order of the following pages
[05:28:22] <Lonesoldier728> right so my solution was to have a fake order
[05:28:34] <Lonesoldier728> by giving them positions
[05:28:41] <Boomtime> so you don't want to sort by viewCount?
[05:28:41] <Lonesoldier728> in a new field that iwll update daily
[05:28:48] <Boomtime> what are your requirements?
[05:29:39] <Boomtime> you can sort by whatever you like, i'm not the one with the requirements - i'm only suggesting _id after whatever you sort by as a way of unambiguously deconflicting duplicates
[05:30:04] <Boomtime> if you have a method that can assure unique positions, then you don't need the _id suggestion
[05:30:12] <Lonesoldier728> To show the most popular items first and being able to grab more data as a user scrolls down
[05:30:55] <Boomtime> a script that runs once a day and assigns a sort order position to every entry would certainly work - it just seems like bringing a bazooka to a poker game
[05:31:00] <Lonesoldier728> the only issue is that the popular items are changing constantly - so to solve that and avoid duplicates I would have to add another field that identifies it with todays
[05:31:19] <Lonesoldier728> Well if you are playing poker with Iran you might just have to : )
[05:32:01] <Lonesoldier728> And you can take that in either way, whether because they will to bring it, or because you probably can put it up as a bet and they will count it as money :)
[05:34:44] <Boomtime> anyway, you have ideas, several i think, what works for you will depend on precisely the behavior you want and how the implementation will perform, etc. good luck
[05:35:22] <Lonesoldier728> thanks, should I index the explorePosition field - is it necessary because I know indexing takes space too
[05:35:36] <Lonesoldier728> and if I change it each day - it will have to re-index no?
[05:36:54] <Boomtime> if you change a field value the index is updated as part of the document update - these two things are atomically performed
[05:37:16] <Lonesoldier728> oh ol
[05:37:18] <Lonesoldier728> ok
[05:37:24] <Lonesoldier728> thanks for your help
[06:42:10] <jasvir> Hey there. I am having two fields in my document which are longitude and latitude. I want to create 2d index out of that. Can anyone please tell that how can I do that.
[07:25:17] <jasvir> ?
[10:33:19] <CreativeWolf> Heya all
[10:33:48] <CreativeWolf> I'm trying to get mongodb working on Pine64 and running in to trouble
[10:34:34] <CreativeWolf> Getting an error message "2016-05-07T15:56:10.575+0530 I STORAGE [initandlisten] exception in initAndListen: 18656 Cannot start server with an unknown storage engine: mmapv1, terminating"
[10:35:35] <CreativeWolf> Googled for about 20+ hours and couldn't get anything that helps
[10:35:46] <CreativeWolf> Can someone help please?
[10:57:30] <hit_> Hi I have a lot of documents and they all have a field, the values for that field are only a small set of about 1000 values. I want to clean all the documents and leave only one for each value of that field. How can I do that?
[12:17:46] <yopp> hum
[13:27:14] <zerOnepal> Hi there, I am adding new replica set to my current pool, currently there are 3 nodes, I am adding on secondary and one aribter... total of 5...
[13:27:34] <zerOnepal> my question is, how to I force added new member not to be able to be elected as master
[13:38:20] <CreativeWolf> heya all
[13:38:26] <CreativeWolf> I'm trying to get mongodb working on Pine64 and running in to trouble
[13:38:28] <CreativeWolf> Getting an error message "2016-05-07T15:56:10.575+0530 I STORAGE [initandlisten] exception in initAndListen: 18656 Cannot start server with an unknown storage engine: mmapv1, terminating"
[13:38:32] <CreativeWolf> Can someone help please?
[14:24:44] <logikos> is it possible to have mongodb store the files under each users account ... can i control where files are stored via php? .. this would make backup of the db files with the account easier
[14:25:42] <StephenLynx> that sounds like a bad idea.
[14:25:51] <logikos> why?
[14:26:13] <StephenLynx> how do your application uses the database?
[14:26:17] <logikos> that is one thing i like about sqlite is it lets you store the db file local
[14:26:20] <StephenLynx> and these accounts?
[14:27:15] <logikos> each account is a client with there own website ... I intend to use mongo for a blog of sorts
[14:27:30] <logikos> i would like each site to maintain its own db files
[14:27:41] <logikos> so when the account is backed up the blog db files get backed up with it
[14:27:43] <StephenLynx> these accounts, they exist on your database or your application?
[14:27:51] <StephenLynx> are these mongodb users or your application users?
[14:27:55] <logikos> on the server
[14:27:57] <logikos> shell accounts
[14:28:24] <StephenLynx> and your application uses the system accounts?
[14:28:40] <StephenLynx> why not have them to be users on the database itself?
[14:31:51] <logikos> I have little to no experience with mongo .. just had an idea and though it may be a good fit .. but basally I write php applications that can be used by one or more clients ... was going to make a blog app that would plug into their existing frameworks .. to use mysql i would have to setup a database, a user, and create tables before the app is usable via php
[14:32:03] <logikos> my goal was to build an app using mongo that did not require such setup ahead of time
[14:32:12] <StephenLynx> well
[14:32:14] <logikos> it could just store the files related to each users blog in that users local account
[14:32:24] <StephenLynx> you can store the files and relate these to each user.
[14:33:04] <logikos> and if the files were local, then I could very easily make a backup of all the files in their account
[14:33:07] <StephenLynx> are you gridfs allows you to have a metadata field where you can store arbitrary data on each file.
[14:33:21] <StephenLynx> if the files are directly on the filesystem, you don`t need mongo.
[14:34:04] <logikos> mongo stores the files directly on the filesystem anyway doesnt it?
[14:34:09] <StephenLynx> no
[14:34:12] <StephenLynx> that is
[14:34:16] <StephenLynx> are you talking about gridfs?
[14:34:19] <StephenLynx> or the database files?
[14:34:40] <logikos> i've only ever messed with mysql and sqlite .. so i dont know the difference
[14:35:06] <StephenLynx> the database files are the binaries representing the database
[14:35:16] <StephenLynx> gridfs is an abstraction for files stored on mongo.
[14:35:21] <logikos> with sqlite .. i can put the db file in the local account, commit and push it up to a private repo .. pull it down to a different server and it runs with the db in tact
[14:35:29] <StephenLynx> good.
[14:35:33] <logikos> I was hoping to do something similar
[14:35:39] <logikos> but i know so little about mongo yet
[14:35:44] <StephenLynx> what are you referring to when you talk about files?
[14:35:58] <StephenLynx> the binary files representing the database?
[14:36:06] <logikos> i supose
[14:36:15] <logikos> as i said, i really dont know anything about mongo
[14:36:15] <StephenLynx> you don`t want to manually backup those.
[14:36:18] <StephenLynx> use a replica set.
[14:36:53] <logikos> clearly I need to do a lot more reading lol
[14:36:57] <StephenLynx> yeah
[14:37:07] <StephenLynx> mongo is complex and powerful.
[14:37:21] <StephenLynx> unlike sqlite that is simple but limited.
[14:38:17] <logikos> I've recently started using PhalconPHP which has good docs and an ODM for using mongo and after reading about the ODM it seemed worth a try
[14:38:21] <logikos> i've not used nosql before though
[14:38:25] <logikos> been using sql for years
[14:38:52] <logikos> i just need to take the time to actually learn how the thing works....
[14:39:07] <StephenLynx> id also suggest trying node.js since you are using mongo.
[14:39:16] <StephenLynx> handling json objects is much more intuitive on it.
[14:41:03] <logikos> thanks .. but sadly I currently lack the time required to read up on it all and I dont really need anything that complex, I can use sqlite for this, i just thought if it were simple it would be a good opportunity to learn mongo for this
[14:41:20] <logikos> and figured a blog would be a perfect use case for a document based system rather than a relational database
[14:41:35] <logikos> but i lack to much understanding
[14:41:39] <StephenLynx> hm
[14:41:44] <StephenLynx> I would digress.
[14:41:51] <StephenLynx> I think a RDB is more suited for a blog.
[14:42:01] <StephenLynx> specially a system with multiple blogs on the same db.
[14:42:18] <StephenLynx> you relate tags, users
[14:42:34] <logikos> what is the best usecase you can think of for mongo
[14:43:14] <StephenLynx> something that isn`t heavy on relations and requires to handle a large amount of data
[14:43:26] <StephenLynx> and that doesn`t have a strict schema
[14:43:32] <logikos> nosql has been on my list to learn for some time now, i have done some reading about it .. some people hate it and say never use it for anything .. others seem to think it is the best fit for everything .. the most accurate answer is to use it when you have non relational data .. but i realy cant think of anything that has no relations
[14:43:37] <StephenLynx> something with many 1-n relations
[14:43:45] <StephenLynx> nosql is a bad term, btw.
[14:43:58] <logikos> what is a better term
[14:44:11] <StephenLynx> there isn`t, you use a more specific description
[14:44:21] <StephenLynx> document database, key-value database, graph database
[14:44:34] <StephenLynx> relational database
[14:44:43] <StephenLynx> these are all on the same category
[14:44:50] <StephenLynx> you could have a relational database that doesn`t use sql
[14:45:06] <StephenLynx> it would be a nosql, but it could have more in common to mysql than to mongo, for examle
[14:47:32] <logikos> i see
[14:47:34] <StephenLynx> it would*
[14:47:52] <StephenLynx> and category is the wrong word.
[14:47:58] <StephenLynx> I meant level of description.
[14:48:27] <StephenLynx> like canine, feline
[14:48:29] <logikos> so mongodb would be of the type: document database
[14:48:32] <StephenLynx> yes
[14:49:28] <logikos> and the best real world example you can think of where a document database is a good fit?
[14:49:33] <logikos> please
[14:50:08] <logikos> I'd like to learn it but I learn by doing mostly .. so I need something to work on .. a project to build
[14:50:22] <logikos> something that I can use to help my clients
[14:50:23] <StephenLynx> you know what a chan is?
[14:50:23] <CreativeWolf> I'm trying to get mongodb working on Pine64 and running in to trouble
[14:50:26] <CreativeWolf> Getting an error message "2016-05-07T15:56:10.575+0530 I STORAGE [initandlisten] exception in initAndListen: 18656 Cannot start server with an unknown storage engine: mmapv1, terminating"
[14:50:28] <CreativeWolf> Can someone help please?
[14:50:41] <StephenLynx> i could give my own project as an example.
[14:50:53] <StephenLynx> but I don`t know if you are familiar what the kind of software it is
[14:50:58] <StephenLynx> with*
[14:51:14] <StephenLynx> and imo, you are going the wrong way about it.
[14:51:20] <logikos> i dont know what a chan is
[14:51:22] <StephenLynx> first you have to find a problem and apply the correct solution
[14:51:29] <StephenLynx> not pick a solution and find a problem to be solved.
[14:51:41] <StephenLynx> you know 4chan?
[14:51:48] <StephenLynx> lynxhub.com
[14:51:50] <logikos> how would i know if mongo is the correct solution
[14:51:54] <StephenLynx> its the site I run it.
[14:52:15] <StephenLynx> you get familiar with the tools it offers, you read on articles and documentation
[14:52:42] <StephenLynx> i heard some people use something called mongoacademy
[14:52:44] <StephenLynx> or university?
[14:52:50] <StephenLynx> that helps you learn.
[14:53:09] <StephenLynx> I learned by trying to use it on a project I had started and a dude suggested mongo
[14:53:18] <StephenLynx> so I prototyped using it and it fit.
[14:53:23] <StephenLynx> so I kept going.
[14:53:31] <StephenLynx> instead of restarting with a different database
[14:53:37] <logikos> yeah... i would need a project that would be useful to me to build
[14:54:26] <StephenLynx> I already told you about its strengths: large datasets, 1-n relations, not reliant on n-n relations
[14:55:56] <StephenLynx> first you have to learn the most basic thing about it:
[14:56:02] <StephenLynx> it doesn`t implement relations.
[14:56:22] <StephenLynx> any relation has to be resolved on application code.
[14:56:37] <StephenLynx> even dbrefs are solved on your application code by the driver.
[14:56:53] <StephenLynx> so lets say that your software requires you to join a fuckload of tables
[14:56:59] <StephenLynx> that would be awful on mongo
[14:57:17] <StephenLynx> because you would have to individually read the data from all collections and perform a join on your software
[14:57:42] <StephenLynx> also because of that, relations are not validated, since foreign keys don`t exist.
[14:58:05] <StephenLynx> even with dbrefs, if you relate a field on a different collection, if said relation is invalid, mongo won`t bother checking for it.
[14:58:29] <StephenLynx> this is a core characteristic and is up to you to understand how it impacts your project.
[15:07:52] <logikos> but everything is relational .. products, orders, customers, inventory, purchasing, accounting, job tracking ..
[15:08:32] <StephenLynx> everything where?
[15:08:39] <StephenLynx> on your system?
[15:09:18] <StephenLynx> because not everything has to be relational and not everything has to implement relations using separate groups.
[15:09:38] <logikos> everything i can think of on the systems i've built for my clients or things on my todo list left to be built
[15:09:47] <StephenLynx> you have lots to learn.
[15:09:57] <logikos> yes i do
[15:10:34] <logikos> which is rather humbling given my position
[15:11:24] <StephenLynx> its better to just not try to draw parallels.
[15:11:31] <StephenLynx> and take mongo for what it is.
[15:11:41] <StephenLynx> and accept that different software have different limitations.
[15:11:53] <StephenLynx> no database is universal.
[15:11:54] <logikos> i understand things based on how i can use them ..
[15:12:00] <logikos> oh i understand that well
[15:12:08] <StephenLynx> let me show you my model
[15:12:13] <StephenLynx> it might help you
[15:12:14] <logikos> I've made many different kinds of applications
[15:12:23] <logikos> but they all involved relational data
[15:12:35] <StephenLynx> is not that you can`t have relational data
[15:12:47] <StephenLynx> is just that you won`t have the database to validate and use the relations.
[15:13:03] <logikos> looking online the best usecase I found for a document system like this would be in describing product features
[15:13:05] <StephenLynx> https://gitgud.io/LynxChan/LynxChan/blob/master/doc/Model.txt
[15:13:19] <logikos> as there are so many different kinds of products and each with a rather unique list of attributes
[15:13:38] <StephenLynx> its hard to use problems as a base because how you have to go about these is important too
[15:15:05] <logikos> I'm paid to solve problems .. that is what programmers do .. we always start with a problem ..
[15:16:11] <StephenLynx> i know
[15:16:20] <logikos> but suppose some day I get a client who's problem is better solved with mongo or some other document based database system .. i'd rather have some experience with it to know for sure
[15:16:25] <StephenLynx> I am just talking about giving you molds
[15:16:33] <StephenLynx> its hard to describe molds for this
[15:16:39] <StephenLynx> moulds*
[15:16:52] <StephenLynx> I can tell you what characteristics you have to look for
[15:17:11] <StephenLynx> but I really don`t know how to give you a whole package
[15:17:25] <logikos> you said 1-n relationships rather than many-to-many .. but most many-to-many relationships are really a 1-n-1 relationship
[15:17:47] <StephenLynx> if its a 1-n-1, it is a 1-n
[15:17:58] <logikos> or n-1-n rather
[15:18:03] <StephenLynx> that
[15:18:07] <StephenLynx> anyway
[15:18:27] <StephenLynx> the thing is that you either have to relate the n part with other n or not
[15:18:31] <logikos> is it common for document databases and relational databases to work together
[15:18:34] <StephenLynx> no
[15:18:36] <logikos> such as the product attribute example i gave
[15:18:47] <logikos> products could be stored relatoinaly but their attributes stored in the document system
[15:18:53] <StephenLynx> pointless.
[15:19:03] <StephenLynx> you might as well store everything on the rdb
[15:19:17] <logikos> except the attributes are difficult to store in rdb
[15:19:24] <logikos> you could use EAV
[15:19:25] <logikos> but that sucks
[15:19:46] <StephenLynx> EAV?
[15:19:47] <aep> jo, any mongo contractors from berlin awake? got something interesting :)
[15:20:06] <logikos> entity attribute value
[15:20:25] <logikos> where tables grow vertically rather than horizontally .. kinda
[15:21:08] <logikos> there are so many product attributes, and many of which wont be used by most products that to have a table contain them all horizontally is not realistic
[15:21:16] <logikos> so instead you have a table of attributes
[15:21:26] <logikos> and another table relating products attributes and values
[15:22:48] <kurushiyama> aep: Cologne, if that helps
[15:25:09] <logikos> it lets you store the data, and you can select the data to output for a product .. but it makes many other queries difficult
[15:25:36] <logikos> because to get a products information it is spread accross many rows
[15:26:27] <kurushiyama> logikos: For MongoDB that does not make much sense. Either you'd simply have the attributes in some docs, and some other in other docs, or you could model an array of subdocs, like {attributes:[name:"power",value:"moa"]}
[15:26:39] <logikos> so if you think of the products on amazon .. how you can select a category and then filter based on various attributes
[15:26:43] <logikos> that would be very difficult
[15:27:21] <kurushiyama> logikos: db.products.find({"attributes.name":"Cool"})
[15:27:23] <logikos> kurushiyama: each document is a product and the list of attributes for the product are within the document
[15:27:37] <logikos> at least that is how i thought it would work from the reading i did the other day
[15:27:40] <kurushiyama> logikos: That is one way to model it.
[15:28:00] <kurushiyama> logikos: The above example excluded the other product fields
[15:28:07] <logikos> yeah
[15:28:40] <logikos> but it can be difficult to ensure the product attribute keys stay consistent when they are related
[15:28:54] <kurushiyama> logikos: How that?
[15:29:10] <kurushiyama> logikos: You'd have to sanitize the input... As always?
[15:29:16] <logikos> well say i'm adding a new product .. and i go to list the attributes for the product
[15:29:37] <logikos> either there needs to be a table with a pool of attribute options or i enter them free form
[15:30:05] <logikos> if they are entered free form .. for one product cordlength=6 and in another cord-length-6
[15:30:40] <kurushiyama> logikos: For fixed attributes, you'd model differently.
[15:30:52] <kurushiyama> logikos: It really depends on what you _want_
[15:31:40] <logikos> well that is the thing, they arr kinda fixed .. in that the same key will be reused for many products but also kinda not fixed because this new product I want to enter has a notable attribute that hasnt been used before .. or that has been used but under a name I can not guess
[15:31:49] <thezanke> o7 Hello #mongodb - quick question.. I'm just ramping up on mongo/mongoose. When I run a `Model.create(stmt, (err, model) => { // handle response });` What's the proper way to only "select" the fields I need from the return object? I don't want to reply with every field in the create response.
[15:31:57] <logikos> and the attribute key list would have to be 10000+ long
[15:31:57] <kurushiyama> logikos: Last time I had a look at amazon, they had whole duplicate trees, let alone the same tag in different spellings.
[15:32:07] <kurushiyama> logikos: How that?
[15:32:43] <logikos> if they have the same tag with different spellings then that suggests it is free form then?
[15:33:12] <kurushiyama> logikos: I am pretty sure about that. But if you want it fixed: np.
[15:33:21] <kurushiyama> logikos: You have different way to do it
[15:33:37] <logikos> for that many different product types and that many different kinds of attributes to make it fixed would be difficult...
[15:33:43] <logikos> but making it freeform has its draw backs also
[15:34:03] <logikos> i realize there are different ways to do it .. i'm trying to think of what would be the best way
[15:34:20] <logikos> wish amazon.com wa sopen source lol
[15:34:28] <kurushiyama> logikos: What I would do is to display the list of available attributes for a product when the user enters it, and then save them either as an array of subdocs or a simple array, if the attributes are no k/v pairs.
[15:35:09] <kurushiyama> logikos: Yes, that is redundant, but saves you quite some queries.
[15:36:38] <kurushiyama> logikos: But imho, you only shift the problem of having unique attributes from one place to the other, and potentially you limit the user or – worse – the usefulness of the application if you are to strict.
[15:39:59] <kurushiyama> logikos: Probably the best way to deal with it is to have some sort of autocomplete for attribute names. Or, more genericly described, to display the existing attributes in one way or the other to choose from. If the user really feels like creating a new one, let him.
[15:50:26] <bruceliu> anyone online
[15:52:06] <bruceliu> *******
[16:22:16] <bruceliu> hi
[16:26:55] <kurushiyama> bruceliu: Just shoot, somebody will answer. Or not. regardless of current online status ;)
[16:56:39] <bruceliu> hi
[16:56:53] <bruceliu> question in mongo
[17:00:34] <kurushiyama> bruceliu: ...?
[17:14:01] <bruceliu> kurushiyama:when i update mongo, timeAcquiringMicros take long time
[17:14:09] <kurushiyama> bruceliu: HDD?
[17:14:51] <bruceliu> kurushiyama
[17:14:56] <bruceliu> kurushiyama: yes
[17:15:21] <bruceliu> but other machine worked fine
[17:15:49] <kurushiyama> bruceliu: From which version to which did you update? Did you change the storage engine? For which query did timeAcquiringMicros rise? A bit more info please.
[17:17:10] <bruceliu> MMAPV update $addToSet
[17:17:53] <kurushiyama> bruceliu: Please pastebin the output of yourQuery.explain()
[17:17:53] <bruceliu> two machines, same hardware, but one is very slow
[17:18:28] <kurushiyama> bruceliu: Are we talking of a replica set or a sharded cluster? If the latter, what is the shard key?
[17:18:35] <bruceliu> not
[17:18:40] <bruceliu> just alone
[17:19:29] <kurushiyama> bruceliu: Please do the same query on both machines, with .explain() added and pastebin the results.
[17:19:29] <bruceliu> maybe some configure case it
[17:19:48] <kurushiyama> bruceliu: Without facts, that is hard to say.
[17:20:16] <bruceliu> update no explain result
[17:20:27] <kurushiyama> bruceliu: That can not be.
[17:20:37] <kurushiyama> db.foo.update(....).explain()
[17:21:52] <kurushiyama> bruceliu: Sorry.
[17:21:56] <kurushiyama> ofc not
[17:22:07] <kurushiyama> Just do the query part, please.
[17:22:18] <kurushiyama> db.foo.find(query).explain()
[17:22:20] <bruceliu> query quickly
[17:22:34] <bruceliu> just update all
[17:23:16] <kurushiyama> bruceliu: I really can not help you without seeing anything. You refuse to give the update, you refuse to give the results of explain. So HOW should I find out what is going on?
[17:24:33] <bruceliu> update simple,just db.test.update({},{$addToSet:{group:1001}})
[17:25:14] <bruceliu> same update but in different machine, one run very slowly
[17:25:29] <bruceliu> i mean just some configuration cause it
[17:26:22] <kurushiyama> bruceliu: Whatever. If you know good enough which information is needed for debugging, then you should know how to debug.
[17:28:29] <bruceliu> thank you, i need to sleep
[19:52:30] <zsoc> Under what circumstances would mongo ignore a fields unique: true attribute and allow a duplicate entry?
[19:53:03] <WarAndGeese> So can I safely avoid data loss in mongodb by trying to attempt a sort of double- or triple-entry accounting system, and then running checks to make sure things like up?
[19:53:09] <WarAndGeese> How often does mongodb lose data exactly?
[19:54:02] <WarAndGeese> Like if rather than saving documents when stuff happens, I can save a document when something is attempted, save another when it's completed, and then run checks to make sure everything adds up, does that make sense?
[19:55:09] <zsoc> Oh It's a mongoose bug. I guess I shouldn't be surprised.
[19:55:19] <WarAndGeese> Or I can even save things twice, that way if one document gets lost I would have the other, and then run checks and find out when there are inconsistencies. Does that solve data loss issues?
[20:18:49] <zsoc> When I'm in a callback of find, and I have an array of documents (doc), can I do something like var first = doc[0]; first.field = 'foo'; first.save(); ? I feel like I should be able to do this.
[20:23:11] <zsoc> Yep, I can. I just can't if my var isn't in scope cos i'm a dolt. Alright coo
[21:02:53] <Lonesoldier728> Hey no idea why I am getting this error MongoError: invalid operator: $search on a full text search am I doing something wrong with my query http://stackoverflow.com/questions/37093606/how-to-conduct-a-text-search-in-mongodb
[21:13:44] <zsoc> Lonesoldier728, what is the $search operator?
[21:14:24] <Lonesoldier728> what do you mean?
[21:14:47] <Lonesoldier728> to search for full text? https://docs.mongodb.com/manual/reference/operator/query/text/
[21:15:50] <zsoc> huh, interesting. Never used it.
[21:16:53] <zsoc> But I don't think that's how it works.
[21:17:52] <zsoc> Lonesoldier728, https://docs.mongodb.com/v2.4/tutorial/search-for-text/
[21:18:37] <zsoc> Apparently the way you are using used to work around 2.4~ but since 2.6+ it's different.
[21:19:01] <zsoc> Or vice versa, so either your version is too old or too new lol.
[21:20:06] <Lonesoldier728> I am on 2.6+
[21:20:11] <Lonesoldier728> so the way I use it works
[21:20:27] <Lonesoldier728> you sent me the 2.4
[21:20:42] <zsoc> Well apparently the way you're using it doesn't quite work as expected lol.
[21:20:55] <zsoc> You're right tho, I had the docs backwards.
[21:21:20] <Lonesoldier728> Right and that is what I am trying to figure out why! )
[21:22:11] <zsoc> I like to blame Mongoose, that's the bane of most of my issues. Maybe the mongoose middleware doesn't like something about $search.
[21:23:49] <zsoc> You might would save yourself some trouble to run db.serverStatus()['version'] in console and make sure there aren't multiple versions hopping around your env
[21:24:34] <zsoc> For instance, the newest version of Mongo on OpenShift is 2.4, as ridiculous as it sounds.
[21:30:06] <Lonesoldier728> it is a mongo error not mongoose
[21:33:47] <Lonesoldier728> MongoDB shell version: 3.0.4
[21:45:44] <kurushiyama> WarAndGeese: Using a proper writeConcern: Never.
[21:46:04] <kurushiyama> WarAndGeese: "How often does mongodb lose data exactly?" ^
[22:04:51] <WarAndGeese> kurushiyama: Yeah? What about all the stuff on the Internet advising against using mongodb?
[22:04:59] <WarAndGeese> I'm trying to find out how credible it is
[22:05:37] <zsoc> WarAndGeese, so don't use it
[22:06:00] <zsoc> alternatively, realize why the vast majority of that stuff is based on people trying to use mongo like it's sql
[22:06:24] <kurushiyama> WarAndGeese: Most of the people complaining did the following: NOT reading the docs.
[22:06:38] <WarAndGeese> zsoc: I'm trying to figure out how credible that stuff is though, if I can use mongo for what I want then I will use it, it would be a big deal for me to have to switch
[22:06:40] <kurushiyama> WarAndGeese: Here is what happens when you set a writeConcern > 1
[22:06:55] <joannac> Lonesoldier728: does it work in the mongo shell, connected to the same mongod?
[22:07:15] <WarAndGeese> Or not just with it being credible, but if it's relevant and if I can get around any issues for my project
[22:07:19] <kurushiyama> WarAndGeese: A write operation will only return when the data has been applied to at least the number of writeConcern Hosts
[22:07:26] <Lonesoldier728> querying it directly? joannac hm let me try
[22:07:42] <zsoc> Realistically, no one would use a db if it randomly lost any amount of data when properly used.
[22:08:40] <Lonesoldier728> joannac - Error: error: { "$err" : "invalid operator: $search", "code" : 10068 }
[22:08:41] <Lonesoldier728> same error
[22:08:53] <Lonesoldier728> db.tags.find({ '$text' : { '$search' : "tech"} }); - this is the query
[22:09:05] <joannac> db.tags.getIndexes() ?
[22:09:13] <joannac> and db.version()?
[22:09:33] <Lonesoldier728> The version is this - MongoDB shell version: 3.0.4
[22:09:44] <WarAndGeese> zsoc: Yeah that's what I was thinking, so I was confused by all flak it was getting, unless I misunderstood what it was for and if it was strictly for cases where you don't need every point, like if you're aggregating a huge amount of information and no individual piece mattered. It's just that I know it's used for more than that and it's throwing me off.
[22:09:46] <joannac> Lonesoldier728: please type what I asked you to type
[22:09:58] <joannac> Lonesoldier728: that is not the output you get from db.version()
[22:10:06] <Lonesoldier728> the indexes here http://pastebin.com/BBHN3X9W
[22:10:11] <joannac> Lonesoldier728: that is your shell version, which is not the same
[22:10:32] <zsoc> WarAndGeese, people complain because they embed documents without understanding when they shouldn't be embedding documents and then 10 million rows later they run into an issue.
[22:10:36] <Lonesoldier728> ahhhhhh thanks
[22:10:37] <Lonesoldier728> 2.4.8
[22:10:43] <Lonesoldier728> Did not realize that
[22:10:49] <kurushiyama> WarAndGeese: Even with a write concern = 1, an operation returns only when the write made it to the primary. There are _rare_ edge cases (namely when a write made it to the primary, but none of the secondaries and a failover happens while this is still true) in which data is rolled back. It is not lost, but manual intervention is needed. With a writeConcern of > 1, you are on a pretty safe side, with a write concern of majo
[22:10:49] <kurushiyama> rity and a replica set size (standard nodes) of 5, it is virtually impossible to loose data.
[22:11:25] <WarAndGeese> kurushiyama: That makes sense, so then if the writeconcern is high and if I have multiple servers then data shouldn't even get lost, like it would have to coincidentially get lost on multiple instances, am I understanding it right?
[22:11:33] <joannac> Lonesoldier728: okay, so you have 2 pronblems. You're on 2.4 which has different text search syntax, and it doesn't look like you have a text index :)
[22:11:58] <kurushiyama> WarAndGeese: you would need to loose all instances on which the write is done _simultaneously_
[22:12:33] <kurushiyama> WarAndGeese: The probability of a fire destroying the datacenter is probably much higher.
[22:12:34] <Lonesoldier728> Yeah the text search index seems to be missing how do I add it? I was doing this in mongoose... Tag.index({name: 'text'});
[22:13:02] <Lonesoldier728> For the query - this should work then - db.tags.find("text", { search: "tech" } ); but yeah the text is undefined - which leaves to the index problem
[22:13:30] <zsoc> index stuffs can only be defined on collection creation, iirc
[22:13:35] <WarAndGeese> So when a document is added or updated or deleted, does it try to make that change in multiple servers, and then if it fails on one or two, does it synchronize after?
[22:13:43] <joannac> Lonesoldier728: https://docs.mongodb.com/v2.4/tutorial/enable-text-search/
[22:13:59] <zsoc> that link looks familiar
[22:14:02] <WarAndGeese> I'm still learning so bear with me if I have noobish questions
[22:14:31] <joannac> Lonesoldier728: did you do that?
[22:14:37] <kurushiyama> WarAndGeese: It is done on one server (the primary) and then put into an operation log (oplog for short) which is pulled (in the sense of a "tail -f" you know from linux) by the secondaries.
[22:14:43] <anamok> hi
[22:15:23] <Lonesoldier728> nope - but is there a way I can upgrade the mongodb version before I continue with 2.4 - or is it because I am using a sandbox on heroku that I probably will not have that kind of permission
[22:15:27] <kurushiyama> WarAndGeese: nuts and bolts aside, but that's mainly how it works.
[22:15:42] <WarAndGeese> The other thing is with ACID compliance, people are saying you can't make changes to multiple documents safely. Like if I have multiple accounts with points in them, and I want to subtract 5 points from one account and add 5 points to another account, is that done reliably as long as I follow proper procedure, or is mongodb just not for that use case?
[22:15:57] <anamok> I have a mongo script with an aggregate. I want to see everything but the result is truncated to 20 lines. I run it with "mongo < script.js". How to have the full output?
[22:15:57] <joannac> Lonesoldier728: no idea. try it and see
[22:16:17] <kurushiyama> WarAndGeese: That is correct. The mistake here is the assumption that it should work like an RDBMS. Let me dig sth up for you.
[22:16:22] <joannac> anamok: what do you mean, truncated?
[22:16:43] <anamok> it says "Type "it" for more", but I'm not in interactive mode
[22:16:56] <kurushiyama> WarAndGeese: http://dba.stackexchange.com/questions/134841/how-can-we-ensure-security-and-integrity-of-data-stored-in-mongodb/134858#134858
[22:18:19] <kurushiyama> WarAndGeese: tl;dr : With proper data modeling, you can achieve _a lot_. Since changes to documents are atomic, you can basically record the change and do an aggregation afterwards, when you need the value for a given point in time
[22:18:37] <WarAndGeese> Thanks kurushiyama, I've come across that thread before but wasn't sure what to trust as I was still learning
[22:19:17] <joannac> anamok: um what? are you talking about a find() ?
[22:19:27] <joannac> oh, you're not talking about 2.4
[22:19:45] <kurushiyama> WarAndGeese: Disclaimer: I am the author of the answer I linked – so it is safe to call me biased ;)
[22:20:15] <anamok> @joannac, I have a db.coll.aggregate([...]) in the script
[22:20:18] <WarAndGeese> Haha, I didn't notice, I think it makes sense though
[22:21:18] <joannac> anamok: https://docs.mongodb.com/manual/tutorial/iterate-a-cursor/
[22:24:42] <anamok> @joannac, var cursor = ...aggregate(...); cursor.forEach(function (doc) { print(doc); }); displays [object BSON] for every doc
[22:25:57] <Lonesoldier728> thanks joannac at least I am in the right direction now, I do not think I can make use of it not - Error: db.upgradeCheckAllDBs() can only be run from the admin database and db.adminCommand( { setParameter : 1, textSearchEnabled : true } ) - gives me an unauthorized message
[22:26:52] <kurushiyama> WarAndGeese: Anything else that worries you?
[22:27:26] <Lonesoldier728> Am I doing that correctly joannac - the way I am enabling textSearch
[22:28:41] <kurushiyama> anamok: Try "printjson"
[22:29:28] <anamok> @kurushiyama, thanks, works now
[22:30:25] <WarAndGeese> I don't think so. My thought process was that I'd have to find a way around the ACID-compliance-related complaints, and the solution I was thinking was like the answer you had on stackexchange. But then other people were saying that you can lose data, and if that happened then I'd be in trouble (e.g. I can have a 'transaction' record that records taking 5 points from user A and adding 5 points to user B,
[22:30:25] <WarAndGeese> but then if data loss is a thing and I lose that document I'm screwed). If the data loss thing was mostly due to a misunderstanding of write concerns and how to properly store redundant data, and if I can reliably/safely get past that by just following proper prodecure, then I shouldn't lose important data and therefore I should be okay, at least I think.
[22:31:46] <kurushiyama> WarAndGeese: Your analysis seems to be about right. Just take care with the data modeling. If in doubt, ask here ;) May I ask which language you will be using for the project?
[22:32:14] <WarAndGeese> I'm also thinking about stuff like saving extra records than I need to, e.g. add a document for attempting to take 5 points from user A and add 5 points to user B, and then add another document when it succeeds, and then run tests to make sure things add up
[22:32:18] <anamok> bye
[22:33:03] <WarAndGeese> kurushiyama: I'm using the Meteor framework, which is all javascript. The only database they support is Mongo, so I assumed it can do everything I need, and I was thrown off reading all the articles claiming it's not reliable or whatever.
[22:33:22] <kurushiyama> WarAndGeese: That is called "2 phase commit". For just pushing points from A to B, it might be using a sledgehammer to crack a nut, but that depends on your use case.
[22:36:43] <WarAndGeese> What if I eventually want to transfer money in the same way? Can it be done safely as long as I do it right? Basically I want to start one thing and if I get any users and if Mongo isn't the right choice then I can start rewriting it in another framework (if I have to), but if Mongodb can do everything safely (as long as I follow procedure) then I wouldn't have to switch. But I don't want to redo a whole
[22:36:43] <WarAndGeese> application before even trying to see if users like it.
[22:37:25] <kurushiyama> WarAndGeese: Aside from the fact that some of those articles simply seem to be clickbait, most of them display a shocking lack of knowledge about the persistence layer they freely chose. The best advice I can give you and as trivial as it may sound: Read the docs. Read how replication works. Read how sharding works. And yes, you can do such things in MongoDB, if you do it right.
[22:38:34] <WarAndGeese> kurushiyama: Cool, this is reassuring. I have been reading the docs but I will keep reading :)
[22:39:43] <joannac> Lonesoldier728: "unauthorised" suggests you need to db.auth(...) first?
[22:39:47] <kurushiyama> WarAndGeese: The example in the answer is obviously a bit oversimplified (as you might have guessed already), since it does not cover some edge cases. But with a 2 phase commit, you'd be on the safe side.
[22:40:49] <WarAndGeese> Nice, thanks again
[22:42:12] <Lonesoldier728> yeah joannac - that is not the problem, it is that I am using a sandbox version on compose.io and I apparently do not have authorization for that
[22:42:21] <Lonesoldier728> even with db.auth(my credentials)
[22:42:39] <kurushiyama> WarAndGeese: You are welcome. To explain those articles a bit more: Quite some of them are from a time when the default writeConcern was quite loose. So people were going with the default one (albeit not matching their durability needs) and complained without investigating the issue any further.
[22:48:44] <joannac> Lonesoldier728: oh. well then, i guess you have to upgrade MongoDB then?
[22:49:01] <joannac> text search is on by default in 2.6+ I think
[22:49:08] <Lonesoldier728> apparently cannot do that either
[22:49:20] <Lonesoldier728> let me see if I switch over to mongolab maybe things will be better
[22:55:04] <Lonesoldier728> ok looks like I am moving to mongoLab - they offer version 3.0.9
[23:04:17] <Lonesoldier728> joannac - I am going to refresh everything so before I start adding all the tags - are you familiar with mongoose and if so is this how I would index it? Tag.index({name: 'text'});