[06:52:39] <sabrehagen> how do i restructure this logic using a query to reduce my number of database accesses? i have a query that returns documents in a certain time range. each document has a device id. for each of those documents i want to see if there is a document matching
[06:53:10] <sabrehagen> that device id in the 10 seconds prior. the initial number of documents can be 40,000+. my logic then sends 40,000 database queries to check the second piece of criteria.
[06:53:28] <sabrehagen> without the aggregation framework, how would i minimise the number of queries?
[06:59:36] <Waheedi> i have added a 4th mongodb node to a replicateset. I'm not sure why i see two primaries in the replicaset
[06:59:58] <Waheedi> while the added server has been added using normal rs.add operation
[07:00:09] <joannac> Waheedi: o.O output of rs.status() please
[08:02:33] <Waheedi> the other thing was, Im not sure why nearest read preference on the query level does not apply the primary as an option to read from
[08:02:48] <Waheedi> I though nearest would be regardless of role
[08:29:46] <Ceunincksken> Kaksike: Can you post your query and some sample data?
[08:36:41] <Keksike> Ceunincksken: I tried running the same exact query with runCommand (you cant use explain with distinct) and it gave me https://gist.github.com/Keksike/517341c5cd1c861ed0bd the upper file
[08:36:48] <Keksike> so it runs perfectly fine if I do it manually
[08:36:59] <Keksike> but when the program does it, its a different situation and runs much slower
[08:39:45] <Ceunincksken> Keksike: But you're saying that on the database it runs fine but from within your application it's slow, is that correct?
[08:40:51] <Keksike> well, yes, if I just do it directly in the mongo shell, it runs in 0ms
[09:43:31] <pchoo> Morning all, I have a question about matching on an array of sub documents - if we take the example here: https://docs.mongodb.org/v3.0/tutorial/query-documents/#specify-multiple-criteria-for-array-elements - how can I find all documents which have a memo from shipping, but not from billing?
[09:47:13] <pchoo> This is for use in an aggregation pipeline, would I be better off unwinding the array of documents, then grouping the information I need, and using $match to find those where billing doesn't exist?
[09:47:59] <Ceunincksken> That would probably be the best solution.
[09:51:19] <pchoo> thanks, I'll investigate that route
[09:59:53] <tantamount> Is there any way to truncate the length of an array?
[09:59:59] <tantamount> During an aggregation projection
[10:18:21] <kurteknikk> Question: I made a stupid mistake of converting a 90GB collection to capped (30GB) in mongodb 2.4, and the query has been running for over an hour with the mongo completely blocked. Is it safe to kill this operation ?
[10:56:28] <alezz> Hi all. Is there a way to $project the _id hex string value in a new field? I need it because I need to $lookup the _id with a foreign field which contains the hex value.
[10:57:45] <Derick> just the hex value, and not the objetid?
[10:57:56] <Ceunincksken> Have you tried the aggregation framework?
[10:58:54] <Derick> Ceunincksken: that's what the $project refers too
[10:59:30] <Derick> alezz: I don't think there is an A/F operator that does that.
[11:01:21] <pchoo> I'm struggling with obtaining the data I want right now :| I have a collection with data like this: {name: 'whatever', states: [{type: 'a'}, {type: 'b'}]} and I want to find all records which have type:a, but NOT type:b in their statues array
[11:02:26] <Derick> pchoo: I think you should use A/F for that...
[11:07:30] <pchoo> that does get me a different result! Thanks! I'll look into it further :)
[11:21:25] <alezz> Yes Derick, it was something like "$project _id.str in my_id_str; $lookup on my_id_str = foreign_id", but I've already searched a lot and I felt the presentiment there's no operator that does that... Thanks for your reply anyway! :)
[11:22:23] <alezz> It would be usefule to have an operator like "$dateToString" also for object ids
[11:29:51] <Ange7> Someone can explain me why when i make "show collections" in mongo shell i have my list of collection but when i try with PHP driver $db->getCollectionNames() i have a empty array ? :/
[11:30:18] <Derick> alezz: yeah, but then again, you can argue that your lookup table should just have used an objectid...
[11:30:27] <Ange7> (my connection work cause if i try in PHP $collection->findOne() i have one document from my collection
[11:30:46] <Derick> Ange7: which MongoDB version, and which PHP driver version?
[11:31:39] <alezz> Derick you're right, but when you work on someone else's code... :D
[12:07:44] <lipiec> Hi, I have multiple MongoDB standalone instances. I would like to run some mongodb command on each of it at the same time. What is the best tool to use?
[13:00:10] <Ange7> Someone can explain me why when i make "show collections" in mongo shell i have my list of collection but when i try with PHP driver $db->getCollectionNames() i have a empty array ? :/
[13:02:53] <Ange7> (my connection work cause if i try in PHP $collection->findOne() i have one document from my collection
[13:15:09] <Derick> Ange7: you need 1.6 for the new listcollections command support
[13:52:08] <alezz> Derick: today I'm very unlucked. I changed the model with a DBRef but... https://jira.mongodb.org/browse/SERVER-14466 shows that looking up through .$id is not currently supported... Yeah!
[16:00:53] <jami> Hi. I'm doing a stress test with ab against a simple node-mongoose-mongodb application. This application just make a single mongoose.connect with default options. After the stress test, all functionality with db logic inside hangs. After the test none of the model. ... .exec(func() { /* never reached */}) callbacks are reached. The application itself is running but mongoose does not work anymore
[16:01:24] <StephenLynx> i suggest you don't use mongoose.
[16:41:07] <hugealt> Is it possible to have per-collection chunk sizes?
[16:43:19] <Waheedi> I must say my issue is a network related issue and has nothing to do with mongodb :)
[18:00:04] <Lachezar> Hey all. N008-ie here. If I have an Customer[name]->* Order [description] (*line) ->1 Product [description]. How do I find all orders that have description that contains some text or their customer's name contains the text, or the name of any of the products in the lines contain the text?
[18:03:04] <daidoji> Lachezar: what kind of notation is that?
[18:04:56] <Lachezar> daidoji: Notation? None. Just made it up db.customer, db.order, db.product . Order has DBRef to customer, and lines that have DBRef to product.
[18:05:11] <daidoji> Lachezar: oh mongo doesn't do joins
[18:05:22] <daidoji> so you'll have to join in javascript or the application
[18:05:38] <daidoji> normalization is the enemy and all that
[18:06:37] <Lachezar> daidoji: So basically I load all DB collections and do join/filter myself?
[18:07:11] <daidoji> Lachezar: yeah, its a philosophy of Mongo to explicitly not do joins in the database
[18:07:37] <daidoji> so you'd have to run three queries with the filters you've run, and then do more queries to get the other data you need from there
[18:07:46] <daidoji> to achieve the same thing as an RDBMS join
[18:08:25] <daidoji> Lachezar: Mongo documentation typically suggests denormalizing your data to achieve best results
[18:08:31] <daidoji> so you may want to do that if its feasible
[18:08:36] <Lachezar> daidoji: Well… That seems to be where I went to, but I was wondering if there aren't any server-side functions to handle that.
[18:09:20] <Lachezar> daidoji: denormalizing 1-* relations is a horror-show, and keeping denormalized data in sync is a nightmare.
[18:09:31] <daidoji> you're preaching the choir bro
[18:09:32] <Lachezar> daidoji: Been there, done that. No thanks.
[18:09:40] <daidoji> I just use Mongo and hang out here a lot
[18:11:16] <Lachezar> daidoji: I'm currently doing it with multiple queries, but it seems really counter-productive to move big arrays of data from the server to the client, just to send them back again :)
[18:14:26] <StephenLynx> complex sub array can bone you hard
[18:14:26] <Lachezar> daidoji: Well… I'm a Java+JPA stooge, so it's relatively easy to move to PostgreSQL (say). But the customer 'heard', that MongoDB scales and is fault tolerant and all that stuff, and said we're using MongoDB.
[18:18:07] <StephenLynx> ok, what is the case? I didn't geti t completely
[18:19:43] <Lachezar> StephenLynx: I have to find all (a page of) all orders that: 1. Have description matching my search, or 2. Have customer whose name matches the search or 3. Have any lines that have products with names matching the search.
[18:21:58] <StephenLynx> I thought you had a complex array and suggested creating a new collection, but since that is not the case, I'm asking for your model.
[18:22:05] <StephenLynx> so I can understand how is your data organized
[18:22:16] <Lachezar> StephenLynx: You want an UML Class diagram?
[18:22:32] <StephenLynx> I think UML refers to software
[19:06:00] <csepulvedab> some one know how set the ntoreturn value?
[19:06:47] <csepulvedab> i see always is 1000, and i hace some querys that need return more than 5000
[20:22:45] <kryo_> hi, i'm thinking of storing a json object in a mongodb collection
[20:23:06] <kryo_> only issue is that the structure of the json object might change
[20:23:16] <kryo_> so i cannot define a schema for it
[20:24:00] <kryo_> is it possible to store the json object directly as a collection?
[20:35:36] <starfly> kyro_: store a JSON document in a collection, structure can change later, but of course, it depends upon how you will use the data as to whether you will need to make all of the documents consistent later
[20:43:33] <Ben_1> is there a way to create a document in java without a key?
[20:51:03] <orriols> Hi. I'm using MongoDB 2.6. I need, using the aggregation framework, to project a field whose value is an array expressions. Is that possible?
[20:51:49] <orriols> the straightforward approach gives the error " failed: exception: disallowed field type Array in object expression"
[20:52:12] <orriols> is there a not-so-obvious approach to achieve this?
[20:56:42] <kryo_> ty starfly, seems like it's not as simple as you say since i'm using mongoose, so i've come up with a different solution instead
[20:57:36] <starfly> kyro_: OK, but nothing I said was incorrect
[20:58:09] <kryo_> yup. it works totally fine for raw mongodb
[20:58:36] <kryo_> just my case is more complicated
[23:50:57] <anidonde> I have a question re: mongo ruby driver. Is this the right place to ask?