I've imported http://www.maxmind.com/en/city (GeoIP City) into MongoDB. There are two collections: blocks and location.
Blocks have start of ip range and end of an ip range and an integer (will make this a MongoID later) indicating a document in the location collection.
ip addresses in are stored as NumberLong in the blocks collection.
I get an ip address and convert it into long with the php function iptolong (http://php.net/manual/en/function.ip2long.php), giving me a value like 3758096128
Now I need to make a query that get me the id from the correct document in the blocks collection and then look up the location in the location collection (with the help of the id)
I can obvious make two queries, but this is not very efficient.
My first step would be something like (in PHP):
$query = array(
'startIpNum' => array('$gte' => $ipLong),
'endIpNum' => array('$lte' => $ipLong),
);
(Still figuring out why above query does not return any data)
But what would be the next step in the process in getting data from two collections?