Currently I have my geojson data stored in this format:
coord: [long, lat],
time: unix timestamp,
property: some property
I would like to find the nearest location with the closest timestamp (lte). The way how I am doing it right now is:
collection.ensureIndex({loc: "2d"})
collection.find(
{coord : {
$near: [xval, yval],
$maxDistance: 200
},
time: {
$lte: time
}
}).sort({time: -1}).limit(1).toArray(function(err, queryResult) {
(did some return 404 and 200 here)
}
When the data size is small, this works. But as my database has been increased to 50G+, this fails (always return 404 saying nothing's found) and I am thinking it is because the way how I query my data leads to slow performance. How should I change my query / data structure to improve and let it work again?