Monday, 10 April 2017

loopback query with near and order filter not working

I have a requirement of service which should have location field so i have done using enableGeoIndexing in mongo Datasource

my problem is:- i have a requirement sorting data using location near and order filters

location should filter the data using lat, lng and order should filter result data in ASC/DESC order of field mentioned in filter

Based on lat, lng given am getting data but order filter is not working but in documentation i found the below thing:

https://docs.mongodb.com/manual/reference/operator/query/near/

Sort Operation

$near sorts documents by distance. If you also include a sort() for the query, sort() re-orders the matching documents, effectively overriding the sort operation already performed by $near. When using sort() with geospatial queries, consider using $geoWithin operator, which does not sort documents, instead of $near.



via Sweetmouni Mounika

No comments:

Post a Comment