PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Friday the 26th of December, 2014

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[03:29:07] <steinen> whats the preferred backup method for a single instance (no replica sets etc) just mongodump + scp to a remote server or use the os ot perform snapshots and use the data files?
[05:57:25] <quydo> hi all
[05:57:40] <quydo> I have a replica set of three nodes
[05:57:49] <quydo> 1 primary and 2 secondary
[05:57:56] <quydo> 2 secondary A, B
[05:58:15] <quydo> I want to set priority read A greater than B (php module)
[05:58:22] <quydo> how can I do it :(
[06:10:00] <joannac> quydo: why?
[06:46:37] <chetandhembre_> I have one shard with 100 GB and other with 10 Gb .. How much time require to balance data between two shard ? is it good idea to have this things in cluster ?
[07:21:41] <joannac> chetandhembre_: dunno, monitor the logs and sh.status() to see how the migration is progressing
[07:25:38] <chetandhembre_> ok
[07:25:38] <chetandhembre_> another thing does my java driver handle read preference incase of cluster setup
[07:25:38] <chetandhembre_> ?
[09:54:18] <chetandhembre__> what does this mean "acceptableLatencyDifference" ?
[10:25:38] <amitprakash> Hi, mongodump is ignoring the query I am passing to it, what gives?
[10:26:04] <amitprakash> mongodump -h HOST -c COLLECTION -d DBNAME --query '{field: {$gte: new Date(1417737600000), $lt: new Date(1418342400000)}}' -o tmp/
[10:26:19] <amitprakash> However, this is dumping all entries in collection instead of those matching the query
[10:41:24] <hemangpatel> Hi
[10:44:40] <hemangpatel> I need to do sort based upon preference.
[10:44:52] <hemangpatel> Here is what i expected : https://gist.github.com/anonymous/efc53fcb5402527aab55
[10:47:17] <modulus^> hemangpatel: you want sort based on value in key/value pair?
[10:47:31] <hemangpatel> modulus^, yes
[10:48:50] <hemangpatel> modulus^, it's same as : http://docs.mongodb.org/manual/tutorial/aggregation-with-user-preference-data/
[10:49:04] <modulus^> eval: $hash{"key1"}="val2"; $hash{"key2"}="val1"; for ( sort { $hash{$a} <=> $hash{$b} } ) { print "key: $_: val: $hash{$_}, "; };
[10:49:54] <modulus^> eval: $hash{"key1"}="val2"; $hash{"key2"}="val1"; for ( sort { $hash{$a} <=> $hash{$b} } keys %hash ) { print "key: $_: val: $hash{$_}, "; };
[10:50:00] <modulus^> hrm
[10:50:02] <modulus^> no eval bot here
[10:50:05] <modulus^> this isn't #perl
[10:50:06] <modulus^> oops
[10:50:18] <modulus^> sorry i just gave you a perl answer
[10:50:21] <modulus^> to your mongodb problem
[10:50:26] <modulus^> wrong chan!
[10:51:19] <hemangpatel> modulus^, no problem
[10:59:52] <modulus^> 02:43 < hemangpatel> I need to do sort based upon preference.
[10:59:52] <modulus^> 02:43 < hemangpatel> I need to do sort based upon preference.
[10:59:52] <modulus^> 02:43 < hemangpatel> I need to do sort based upon preference.
[10:59:56] <modulus^> oops
[10:59:56] <modulus^> sorry
[11:21:33] <hemangpatel> anyone ?
[11:28:23] <hemangpatel> I want to sort by specific value of key.
[11:31:46] <modulus^> hemangpatel: what's your current find() query look like?
[11:32:19] <modulus^> hemangpatel: you can look here: http://docs.mongodb.org/manual/reference/operator/meta/orderby/
[11:32:37] <modulus^> db.collection.find( { $query: {}, $orderby: { age : -1 } } ) <--- decending by age values
[11:32:46] <modulus^> db.collection.find( { $query: {}, $orderby: { age : 1 } } ) <--- ascending by age values
[11:33:28] <hemangpatel> suppose i want first records which has age 20 then ?
[11:33:40] <hemangpatel> db.collection.find( { $query: {}, $orderby: { age : 20 } } ?
[11:33:53] <hemangpatel> modulus^, I think that's not possible
[11:37:13] <modulus^> db.collection.find( { $query: {}, $orderby: { age : 1 } } <--- that will sort by age in ascending values of age
[11:39:15] <steinen> is there a nice way to keep a count field in a document which refers to the number of documents of a particular type in a separate collections? eg have a cars document with a number field that gets its value from the automobiles collection which has a number of docs with type: car
[11:40:17] <steinen> have the number field in the cars doc be determined by a count query somehow
[11:54:59] <modulus^> hemangpatel: you can try this too: db.collection.find().sort( { $natural: 1 } )
[12:05:23] <chetandhembre__> can i delete _id_ index in favour of _id_hashed ?
[12:07:19] <Naeblis> Is there any way I can ensure that the { field: _id } for my query should return if and only if the document with _id exists?
[12:07:54] <Naeblis> I have some bad data so documents have a field: id but the corresponding objects aren't there. I want to filter those out in my query
[12:08:25] <Naeblis> I tried $exists: true, $ne: null, but I suppose that only checks for the "id" field itself, not the related document
[12:09:12] <basiclaser_> are there any free storage sites where i can keep a mongoDB?
[12:09:39] <basiclaser_> i made a browser plugin that needs one, but I dont want to really pay for it until i know people are going to use it
[12:10:27] <chetandhembre__> use mongolab ?
[12:10:31] <chetandhembre__> *.
[12:37:43] <steinen> if I run an insert or remove can I be guaranteed that in the callback function that the inserted/removed documents willl be reflected in any queries that I run from the callback?
[12:38:24] <steinen> or might they be staged to be written and I get uncertain results from queries in the cb
[12:40:01] <steinen> if I want to run a count query for example after inserting/removing
[13:05:09] <basiclaser_> oh yeh ofcoourse thanks
[14:11:24] <steinen> is there any way to limit the number of insertions for a bulk insert?
[15:21:15] <chetandhembre_> how can i divert my write to particular shard ?
[15:21:29] <chetandhembre_> can any one help me here ?
[15:24:20] <cheeser> why would you want that? you write and let mongos route it to the appropriate shard. that's the point of sharding.
[15:34:15] <chetandhembre_> one of shard is having large data than other
[15:34:35] <chetandhembre_> cheeser:
[15:38:36] <cheeser> sounds like a faulty shard key
[15:44:25] <chetandhembre_> actually i started with replica set which has about 100 GB of data and added another shard with 0 GB
[15:44:44] <chetandhembre_> typical converting replica set to sharding cluster case
[15:53:13] <chetandhembre_> cheeser:
[16:02:19] <biggies> http://pastebin.com/8CiJ5vMb "cannot use the part (records of records.Hover) to traverse the element ({records: []})'" in line 21
[16:18:58] <biggies> how to insert something in my subdocuments arrays ?
[16:19:29] <cheeser> $push
[16:21:09] <biggies> cheeser like insert($push) ? i want to insert into a already existing document
[16:21:39] <cheeser> you can either $set to set/create a field or $push to create/append an array
[16:22:31] <biggies> cheeser do u use php with mongodb ?
[16:22:36] <cheeser> i don't
[16:29:00] <biggies> cheeser well i doing this http://pastebin.com/30DydhJH when i want to add more items to that records than it just replacing the currently i created
[16:29:43] <biggies> cheeser i want to create more "records" not allways change the existing.
[16:30:10] <cheeser> $set will replace anything that's there already.
[16:30:14] <cheeser> is records an array?
[16:31:27] <biggies> cheeser yes
[16:31:45] <cheeser> then you want $push
[16:31:53] <cheeser> the mongod docs cover all this
[16:32:22] <biggies> cheeser when i replace $set instead of $push in my example it says that records is not array that it is a object lol ..
[16:33:07] <cheeser> "lol"
[16:33:20] <biggies> cheeser :D
[16:33:29] <biggies> cheeser arrays basically is {}
[16:34:11] <biggies> cheeser array is a "field" that holds more "fields" : "values" don't ?
[16:35:50] <cheeser> i know what arrays are...
[16:37:20] <biggies> cheeser i just asking if i'm right
[16:38:08] <cheeser> arrays are typically wrapped in []. in the mongo shell that's how you'll see them.
[16:38:38] <biggies> cheeser however when i trying to go with 'dots' like $push records.chata it does not work because chata is not created already.
[16:39:21] <biggies> cheeser my point is to save my custom array indexes like records {chata: array, mynextindex : array} i don't want 0,1,2,3,4 this creating $push
[16:39:32] <cheeser> if you try in the shell, i can help you. i can't help you with the php syntax because i don't know php
[16:39:50] <cheeser> "custom array indexes?"
[16:40:24] <biggies> cheeser when you use $push it will create for you 0 : array , 1 : array, 2 :array right ?
[16:41:27] <cheeser> you won't see numbers at all. you'll just see [ a, b, c ]
[16:41:34] <cheeser> this is how arrays work
[16:46:55] <biggies> cheeser db.test.insert({username:'alex', records:[ ]}); ok how i can with update add to records:[ ] new arrays like records:[ chata:[], chatadole:[] ] ? this is shell commands.
[16:47:37] <cheeser> records wouldn't be an array then. it'd be a (sub)document.
[16:48:00] <cheeser> then you could just $set records.chata and records.chatadole
[16:54:13] <biggies> cheeser why i can't find my record by _id db.users.findOne({_id:'549d8e3348177e2f098b456b'}) ?
[16:54:38] <biggies> cheeser returns null but it exists
[16:54:39] <cheeser> because _id is probably not a string but an ObjectId
[16:54:58] <biggies> cheeser so i can write it in there objectId ?
[16:55:45] <biggies> cheeser ObjectId() ok
[17:44:34] <ilhami> hello
[17:44:48] <ilhami> biggies: oh you are here.
[17:45:02] <biggies> ilhami yeah :D
[17:45:27] <biggies> ilhami i found out that array and subdocument is not the same in mongodb
[17:45:42] <ilhami> http://stackoverflow.com/questions/10285987/mongodb-how-to-query-nested-arrays
[17:45:53] <ilhami> can this help you in any way?
[17:46:01] <ilhami> what is it that you are trying to do?
[17:46:19] <biggies> ilhami when i want to create in mongodb a field 'records' to be a subdocument i doing records: {} ?? and when i want records to be array i do records : [] ?
[17:47:37] <ilhami> {} this is bascially an object
[17:47:41] <ilhami> and [] is an array
[17:50:03] <biggies> ilhami yea and i will find out how to do it in php when i doing $array['records'] = array(); it is basically [] in mongodb but when i want create a new object .. {} i dont know how in php.
[17:51:18] <ilhami> http://php.net/manual/en/mongocollection.insert.php
[17:51:21] <ilhami> check this
[17:54:17] <biggies> ilhami maybe i should create json format and decode it to arrays
[18:18:08] <GothAlice> biggies: On the array/subdocument thing, and I hesitate to mention this, but behind-the-scenes arrays _are_ stored as mappings. http://bsonspec.org/spec.html < see the first note here.
[18:20:00] <GothAlice> I shudder to think of what happens when you $pop a value… one assumes all elements after the popped one(s) are re-numbered. That further encourages me to make stack operations truly stack-like; push/pop on the right for best performance.
[18:23:04] <GothAlice> biggies: PHP treats "lists" and "mappings" as the same thing—both are array(). PHP refers to mappings as "associative arrays" and uses a slightly different syntax when constructing them. Oddly they introduce mappings first in the documentation: http://php.net/manual/en/language.types.array.php — example 4 is the first one treating them as a list. Interestingly, PHP treats lists and mappings in roughly the same way BSON does, though
[18:23:05] <GothAlice> MongoDB does differentiate them.
[18:24:56] <biggies> GothAlice but in json u can do array : [] and object : {} in arrays u can not do this .
[18:26:01] <GothAlice> array("foo", "bar", "hello", "world") vs. array("foo" => "bar", "bar" => "foo")
[18:26:17] <GothAlice> Translates quite directly, actually.
[18:27:07] <biggies> GothAlice and can i create a object in arrays ? so i basically have a subdocument in mongodb i mean "{}"
[18:30:20] <biggies> GothAlice u know what i mean in mongodb i can do this : "db.users.insert({ name:'kokot', ob:{} })" how i can do this in arrays i mean when i do array('name'=>'kokot', ob=>array()) this is not the same as ob will be [] (array) not {} (object) in mongodb
[18:49:15] <GothAlice> biggies: You might be able to create a temporary variable of an array containing a single named value, then delete the named value. However, this is an usual approach. One generally never wants, nor needs, an empty subdocument.
[18:51:16] <GothAlice> (And that temp var approach is a hideously ugly unforgivable hack. ;)
[18:51:31] <GothAlice> (If it even works. I don't PHP. ¬_¬)
[18:57:00] <biggies> GothAlice dear Goth i realized now what u wrote i get it now ... thanks in bson , json basically list are arrays and mapps are objects :)
[19:28:37] <GothAlice> biggies: JSON = JavaScript Object Notation. {} = object in JS, correct. {foo: 27}.foo == 27
[19:52:31] <_roland> Is there a way to project the array index in the results of the $unwind operator in an aggregation pipeline?
[22:30:01] <mcgullen> Hi! Anyone using Morphia experienced compilation error on UpdateResults<T> after upgrading from 0.107 to 0.109?
[22:32:15] <cheeser> pastebin the error
[22:44:08] <mcgullen> Thanks. I understand that morphia's move from 0.107 to 0.108 removed some deprecated methods. I don't think the update method on BasicDAO is one of them, and that's what seems to be causing the compilation error. Pastebin: http://pastebin.com/H6Ay8CzS
[22:46:10] <_roland> Is there a way to project the array index in the results of the $unwind operator in an aggregation pipeline?
[22:46:23] <_roland> $unwind stage, sorry.
[22:48:14] <cheeser> mcgullen: the generic parameter was removed because it wasn't actually used.
[22:57:55] <mcgullen> cheeser: thank you for pointing me to the right direction. If I remove the generic parameter from UpdateResults, the compilation error would read: cannot find symbol, variable results of type UpdateResults. Eclipse would also complain that it should be parameterized. This is confusing, because the compilation error shows in maven compiler, not eclipse...
[22:59:23] <cheeser> never trust eclipse
[22:59:39] <mod^> wtf
[22:59:41] <mod^> IDE?
[22:59:53] <mod^> eclipse for mongo commands?
[22:59:55] <mod^> odd
[23:00:04] <mod^> i thought json was pretty straight forward
[23:00:33] <cheeser> what?
[23:01:10] <mod^> huh?
[23:03:12] <biggies> i have a subdocument records.chata and here i have a array, i want to add another array to this existing one what do i need ?
[23:11:45] <mcgullen> Thanks guys. Fixed.