I am using loopbackjs Geopoint functionality to query based on geolocation.
This is my query:
var loopback = require('loopback');
var here = new loopback.GeoPoint({
lat: lat,
lng: lng
});
Asset.find({
where: {
Location: {
near: here,
maxDistance: 3,
unit: 'kilometers'
}
},
limit: 10,
order: 'id DESC'
}, function(err, data) {
if (err) {
return error;
}
return data
});
Collection schema :
{
"Location": {
"lat": 19.230755,
"lng": 72.838024
},
"key": "value",
//....,
"id": "5829a3eb95dbcc63da37f48f"
}
This collection has almost 150,000 records. When I use near query, the CPU usage exeeds 100% and after 4-5 consecutive API calls to get the same data, server stops responding.Tried indexing the data but no use, still the same issue persists. Please help.