EDIT: it turns out it’s NOT a problem.. pfew! phpMOadmin is not able to display the bigint (probably server apache settings i didn’t care).. not mongoDB is unable to save… u.kodingen.com/1fMs5Z i requested from CLI, and it comes back just fine! sorry mongodb.
when i insert tweet to mongodb, it’s id e.g. 16906830606 becomes -274549723
our servers are 64bits, I use php mongo driver.
this is the full insert code,
$content = file_get_contents("http://search.twitter.com/search.json?q=worldcup");
$decoded = json_decode($content,true);
$c = new Mongo("mongodb://x:pass@mng.vps.kodingen.com:27017");
foreach($decoded['results'] as $tweet)
{
$tweet['_id'] = $tweet['id'];
$c->db->tweets->insert($tweet);
}
This is how it saves: http://u.kodingen.com/1fKw6E
If I force it as String,
$tweet['_id'] = "" . $tweet['id'];
then it’s correct: http://u.kodingen.com/1fKy8g
I want to know why this happens, and what else I should be worried about MongoDB while you are at it 🙂 just starting out here..
The _id field, that usually stores an ObjectID, is 12 bytes. A 64-bit integer is 8 bytes. Obviously it has to be converted in some way. As it seems, not in a very good way.
The fact that
the timestamp and counter fields must be stored big endiancould also be in play.I would consider not using the tweet id as ObjectID since you can’t be certain that they don’t add a couple of digits to it tomorrow.