PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Wednesday the 21st of May, 2014

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:48:52] <blast_hardcheese> I inherited a Mongo project at work; I've got the basic concepts down, and I've played a bit with redis before. What is the mongo way to search for all documents that have a field within a field? I don't care about the value, just so long a they exist.
[00:49:50] <blast_hardcheese> This database has millions of entries in it, searching via {"outfield.infield": {$exists: true}} takes 5 minutes
[00:59:05] <cheeser> blast_hardcheese: is there an index on that field?
[01:26:34] <blast_hardcheese> cheeser: There isn't, but that was the solution. Thank you very much.
[01:27:58] <cheeser> np
[03:41:49] <chovy> if i add an index later, will old docs get indexed or only new ones?
[03:56:59] <cheeser> chovy: they'll all get indexed. that's how databases work.
[05:39:19] <MichelW> wow !!! 'full' channel!
[09:28:32] <greybrd> hi guys. the reduce function is not happening if a key is not having more than one value in it's array. is there a work around to make it happen?
[09:31:17] <kali> greybrd: maybe you can use the finalize function. also be aware that some keys can go through reduce() more than one time
[09:35:06] <greybrd> hmmm.. yeah. how can I do that? any pointer over the net?
[09:36:23] <kali> greybrd: http://docs.mongodb.org/manual/tutorial/map-reduce-examples/ ?
[09:53:09] <greybrd> kali: thanks for the link. but I couldn't find any solution to my problem in that link.
[09:54:06] <greybrd> my problem is, I'm trying to convert the unit of price from INR to USB. so, for the keys which have only one value, the output collection has got the unit in INR as such. where as other keys, with multiple values, have unit in USD.
[09:57:57] <Industrial> Hi. Can I find collections by name matching x?
[09:58:51] <Industrial> db.collectionNames, I guess
[10:45:57] <arussel> is there a way to do a query on the default _id as a date ? (to find all doc older than 20 minutes ago ?)
[10:49:04] <arussel> I can't use:{ ObjectId("507c7f79bcf86cd7994f6c0e").getTimestamp() : {"$gte": 1234 }}, can I ?
[11:16:45] <kali> arussel: db.col.find({ _id : { $gt: ObjectId((Math.floor(new Date().getTime()/1000) - 20*60).toString(16) + "0000000000000000") }}
[11:17:14] <arussel> kali thanks
[12:34:40] <richthegeek> is there any way to set "slaveOk" true permanently?
[12:39:50] <mylord> how do i do update a if a > x?
[12:42:28] <Industrial> mylord: did you check any documentation on the DSL/query language of the database you're working with?
[12:42:49] <mylord> i’m working on node.js .. checking but haven’t seen yet
[12:43:45] <mylord> it might be this: collection.update(criteria, update[[, options], callback]);
[12:44:05] <Industrial> http://mongodb.github.io/node-mongodb-native/
[12:49:30] <wawrek> is there a way of querying array intersections in mongodb? In the mongo documents structure I have a list field called 'ancestors'. I want to get all documents for a list of possible parents.
[12:50:26] <wawrek> or do I need to use map reduce
[12:50:38] <wawrek> in order to achieve that.
[12:51:07] <kami> hi
[12:54:04] <kami> I read since version 2.10 of the java mongo driver there is background thread that check for the connection to the server
[12:56:02] <kami> is there a way to invalidate the connections when the thread detects a disconnection?
[12:59:07] <cheeser> the driver will do that for your
[12:59:08] <cheeser> you
[13:06:08] <kami> I thought it might do it for me but I tried with version 2.12.2 and it does not work
[13:08:27] <kami> I tried to play with the heartbeat* properties
[13:12:11] <cheeser> it should work just fine but if you can create testcase so we can recreate, we can take a look.
[13:16:00] <kami> ok let me see
[13:36:12] <jaizza> hello
[13:40:13] <rspijker> hi
[13:49:19] <kami> where should I send the testcase?
[13:50:01] <cheeser> jira.mongodb.org. file a ticket under the JAVA project.
[13:50:56] <mylord> does this look ok from node: collection.findAndModify({"tid":tid,"uid":uid,"score":{"$lt":score}}, {"score":score}, {upsert:true, new:true, safe:true}, function(err, result) {
[13:51:47] <khinester> hello, i am running freebsd with ZFS, what would be the correct options to use for the zpool/data
[13:53:49] <mylord> ^ i’m seeting result is null
[13:53:51] <wawrek> I would like to run this query but it does not work.
[13:54:25] <wawrek> db.docs.find({$where: "['537c7747e525e736f50b2826', '537c7747e525e736f50b2830'].indexOf(this.ancestors.slice(-1)[0]) >= 0"})
[13:54:51] <wawrek> ['537c7747e525e736f50b2826', '537c7747e525e736f50b2830'] are possible parent ids
[14:01:22] <saml> what's $where?
[14:02:32] <saml> wawrek, give me example doc
[14:02:33] <wawrek> it is a query operator: http://docs.mongodb.org/manual/reference/operator/query/where/
[14:03:00] <wawrek> the code that follows where is a chunk of javascript
[14:03:04] <saml> db.docs.find({ancestors: {$in: ['537c7747e525e736f50b2826', '537c7747e525e736f50b2830']}})
[14:03:06] <wawrek> $where
[14:03:42] <wawrek> saml: I want the last items of ancestors to be in ['537c7747e525e736f50b2826', '537c7747e525e736f50b2830']
[14:04:11] <wawrek> that is why I use where . in javascript this code returns true: [1,2,3].indexOf([5,2,6,3].slice(-1)[0]) >= 0
[14:04:24] <saml> wawrek, so ancestors should have at least 2 items and it should end with 'A', 'B' ?
[14:04:48] <saml> {ancestors: ['foo','A','B']} matches?
[14:05:05] <saml> {ancestors: ['A','foo', 'B']} and this does not match?
[14:05:05] <wawrek> ancestors can have many 0 or items
[14:05:26] <saml> just give example docs and show us which docs you want
[14:05:39] <wawrek> what is important in ancestors is the last item: B in your case
[14:07:32] <saml> usually you duplicate things. {ancestors:[1,2,3], mostRecentAncestor:3}
[14:08:20] <_rgn> hey a question, if I do update({ _id: { $lte: ObjectID(uptoId) } }) is the order of ids guaranteed to be the order they were inserted?
[14:09:34] <saml> no
[14:10:34] <wawrek> here: http://pastie.org/9196110
[14:13:05] <_rgn> so what can I do to update up to and including a specific id, in the order they were inserted?
[14:14:19] <saml> wawrek, db.docs.find({$where: 'this.ancestors[this.ancestors.length-1] in [3,8]'})
[14:15:59] <wawrek> saml: thanks, I will try it , it looks very neat
[14:16:48] <saml> wawrek, db.docs.find({$where: function() { return [3,8].indexOf(this.ancestors[this.ancestors.length-1]) >= 0; }})
[14:17:24] <saml> _rgn, _id is roughly sorted by document creation date
[14:17:51] <saml> so if you don't care for few docs off, that's fine
[14:18:09] <saml> sorting on an _id field that stores ObjectId values is roughly equivalent to sorting by creation time.
[14:18:31] <saml> The relationship between the order of ObjectId values and generation time is not strict within a single second. If multiple systems, or multiple processes or threads on a single system generate values, within a single second; ObjectId values do not represent a strict insertion order. Clock skew between clients can also result in non-strict ordering even for values, because client drivers generate ObjectId values, not the mongod process.
[14:19:00] <saml> _rgn, instead, just query docs that falls into "old" criteria and update them
[14:19:13] <saml> _rgn, what kind of update do you want to perform?
[14:19:30] <saml> give us example docs containing "good" docs that don't need update and "bad" docs
[14:20:39] <kami> I vreated a jira: https://jira.mongodb.org/browse/JAVA-1252
[14:22:00] <saml> kami, did you sign?
[14:22:14] <wawrek> saml: thank ypu very much
[14:22:19] <wawrek> you
[14:22:53] <kami> sign what?
[14:23:26] <saml> kami, http://www.mongodb.com/legal/contributor-agreement
[14:23:57] <saml> i'm gonna have to reject tickets reported by users who did not sign contributor agreement
[14:24:26] <_rgn> saml: alright. https://gist.github.com/raine/9ecdefe605801387577d
[14:24:55] <saml> oh i see
[14:25:17] <saml> _rgn, time is what you inserted just to test ordering of _id ?
[14:25:40] <_rgn> there's time field also
[14:25:53] <saml> why not use time instead of _id ?
[14:26:01] <saml> i mean, what's time ?
[14:26:26] <_rgn> time is not same as object creation time
[14:26:55] <saml> your update looks good to me
[14:27:21] <saml> db.coll.update({ _id: { $lte: ObjectID('537cac29d42b7d4bf930d4e2'), seen: false }}, { $set: { seen: true } }, { multi: true, upsert: false })
[14:27:38] <_rgn> the _id is basically same as creation timestamp right?
[14:28:14] <saml> basically, yes. but not exactly. http://docs.mongodb.org/manual/reference/object-id/#ObjectIDs-BSONObjectIDSpecification search for "sorting on"
[14:28:15] <kami> I signed
[14:28:38] <saml> great
[14:31:46] <saml> maybe there's a way to paginate/partition/sort by _id.getTimestamp()
[15:13:06] <ckrough> hello hello. Does anyone know what opcounters.command includes (from serverStatus)?
[15:13:19] <ckrough> it seems to include all of the other opscounters, plus some other stuff
[15:13:32] <ckrough> cant find definitive docs on it
[15:58:19] <superhans> Hi! Mongoose questions ok in here aswell?
[16:11:45] <Industrial> Hi.
[16:12:06] <Industrial> I'm doing several aggregations in parallel, writing them to collections and then doing find() on all the 'output' collections
[16:12:19] <Industrial> In my app, I'm trying to merge these collections into a CSV
[16:13:33] <Industrial> Somehow I'm having the weird behaviour that when say I have 5 streams from a .find().stream() and I know for sure there is data in each
[16:14:07] <Industrial> I'm randomly NOT getting any data event or end event
[16:14:12] <Industrial> from some of the streams
[16:14:41] <Industrial> Has anyone else ever experienced this behaviour? doing a query where there clearly is data to send and not receiving the data? everything else is ok, all the connections, etc.
[16:23:59] <inad922> hello
[16:24:48] <inad922> If I have a bson.dbref.DBRef object how do I query the associated object with pymongo?
[16:27:08] <jimpop> can a text query exclude certain fields? i.e. {$text: {$search: 'blah'}},{ blob: 0}
[16:28:26] <jimpop> and by exclude I mean to exclude from the results (not the query)
[17:28:40] <raulhugo> Hi everybody
[17:29:06] <raulhugo> someone speak spanish?
[17:37:00] <cheeser> nein
[18:55:22] <dgarstang> What does this mean? "errmsg" : "could not verify config servers were active and reachable before write" ? Config servers are up and available.
[18:58:50] <dgarstang> God, I've been at this for days. I am ready to throw mongo against the wall.
[19:25:08] <mylord> how can i find docs that contain a subdocument named “user_id”?
[19:25:22] <tscanausa> yes
[19:26:04] <tscanausa> db.thing.find({'user_id: $exists})
[19:26:21] <tscanausa> or db.thing.find({'user.user_id: $exists})
[19:40:55] <dgarstang> Weeeee "replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)"
[19:55:57] <Warfront1> after using mongodb i think I love mysql
[19:57:40] <deepy> If you think you love MySQL then you have Huge Issues(tm)
[19:57:46] <ranman> Warfront1: have you also used mysql?
[19:58:42] <Warfront1> First time using mongodb, with a javascript framework called meteor
[19:59:05] <ranman> dgarstang: can you outline how exactly you spun up this cluster?
[20:00:52] <ranman> OS, mongodb version (2.6.1 if I remember correctly)
[20:00:58] <ranman> I'm going to attempt to repro
[20:52:03] <mortal1> howdy folks, I'm coming to mongo from other sql based dbs, how does one find a particular property off a document?
[20:53:25] <mortal1> i tried find({_id:"1"}).someProperty
[20:53:40] <mortal1> as, you know that'd work in js right?
[21:03:22] <ranman> mortal1: you're actually getting back a cursor or an array from find
[21:03:24] <rybnik> mortal1 please note that find() will return a cursor so you should call toArray() on that find() and as you can imagine the result will be an array. Perhaps you should consider findOne
[21:03:30] <ranman> so you'll need to select an element [0]
[21:03:45] <ranman> and then you'll have access to that particular element's properties
[21:03:57] <ranman> you can also project fields out or into a document with the second argument to find
[21:03:57] <mortal1> ok
[21:04:49] <mortal1> ranman: I tried find({_id:"1"},{fieldName})
[21:05:02] <mortal1> I guess I don't get the whole projection thing
[21:05:12] <mortal1> will try the array prop
[21:05:16] <ranman> mortal1: find({_id: 1}, {fieldName: 1})
[21:05:22] <ranman> mortal1: find({_id: 1}, {fieldName: true})
[21:05:26] <ranman> mortal1: find({_id: 1}, {fieldName: false})
[21:05:37] <ranman> includes or excludes as you would expect
[21:05:41] <mortal1> ranman: I just want to select fieldname from the result
[21:06:01] <mortal1> i.e. my field is hugely complex, I just want to simply show the contents of that field
[21:06:22] <mortal1> not really query for it, id:1 is suffecient for that
[21:06:43] <ranman> findOne(query, {'_id': false, 'fieldName': true})
[21:07:39] <mortal1> ranman: hmm
[21:07:47] <mortal1> well the [0].prop worked
[21:08:29] <mortal1> man i wish mongo had a 'sql' syntax mode
[21:08:29] <ranman> http://docs.mongodb.org/manual/tutorial/project-fields-from-query-results/
[21:08:45] <ranman> ... why?
[21:08:48] <ranman> that makes no sense
[21:09:15] <mortal1> I mean yes i know it's a nosql db, but I'm familiar with the query syntax for oracle, pg, etc
[21:09:26] <mortal1> also, don't tase me bro :D
[21:09:47] <mortal1> thanks for the link
[21:10:19] <ranman> I think there's a hive wrapper or something that will let you use sql-esque syntax with mongodb, I've never used it though
[21:10:25] <ranman> mortal1: NP, GL
[21:11:51] <mortal1> oh i get the include thing now
[21:11:59] <mortal1> field:1 = show
[21:12:09] <mortal1> which... is intuitive
[21:31:53] <LouisT> how do i add the first admin user?
[21:35:03] <Joe_knock> Hello
[21:35:53] <Joe_knock> I'm looking for a REST tutorial using Flask and MongoDB that doesn't use MongoEngine. Any recommendations?
[21:52:11] <LouisT> how do i add the first admin user?
[22:07:59] <durango> Is there anyway to sort by a subdocument's value?
[22:08:03] <durango> Such as "market.name" ?
[22:11:06] <federated_life1> durango: yea, in your app
[22:11:39] <durango> Np app.. just mongo
[22:27:03] <federated_life1> durango: no mongo, just app
[22:51:52] <astroduck> Hi! is there any $nand operator in mongo?
[22:53:12] <astroduck> I guess not, as its not listed here: http://docs.mongodb.org/manual/reference/operator/query/, but why not? I mean, here is $nor for opposite of $or, so why not $nand?
[22:57:11] <mikebronner_> astroduck: have you tried $not
[22:57:58] <mikebronner_> astroduck: http://docs.mongodb.org/manual/reference/operator/query-logical/
[22:58:38] <astroduck> mikebronner_: doesn't $not work for only 1 condition?
[22:58:57] <mikebronner_> it is the opposite of $and
[22:59:13] <mikebronner_> you can nest many conditions within brackets after not
[22:59:17] <mikebronner_> and they will all apply
[22:59:31] <mikebronner_> as far as I know
[23:00:27] <mikebronner_> but it looks like it can only compare against a field, and not between multiple sets of expressions
[23:01:08] <mikebronner_> i guess a test case would be in order
[23:06:08] <astroduck> mikebronner_: oh ok, i guess nand would've been helpful in some cases, but oh well, it is what it is ...
[23:08:33] <mikebronner_> yea, i see what you mean
[23:08:54] <mikebronner_> i guess you need to be creative in your not and nor ussage to make up for nand