Sep 22nd, 2012, 01:18 PM
MongoDB GeoNear Query with excluding/including fields criteria
Hi, I don't know if I am doing something wrong or it is a bug. I have the following code:
Query criteria = new Query(Criteria.where("locationTime").gte(
NearQuery query = NearQuery.near(point).maxDistance(maxDistance)
GeoResults<Profile> result = mongoTemplate
I am executing the query and profiles near by retrieved correctly according to distance and the "locationTime" criteria but it seems to ignore the excluded field and retrieving the profiles with their friends.
When I use simple query the exclude/include fields works perfectly.
I looked every where and could not find any resemble use-case, please let me know if i am doing something wrong.
I have a similar problem. In my case it does not work the sort:
Query query = new Query();
query.with(new Sort(Direction.DESC, "timeStamp"));
Criteria criteria = new Criteria();
NearQuery queryN = NearQuery.near(p).maxDistance(new Distance(distance, Metrics.KILOMETERS)).num(range).query(query);
GeoResults<MeasurementPoint> geoPoints = mongoTemplate.geoNear(queryN, MeasurementPoint.class);
I do not know what I am doing wrong but the geoResult returns me the first match, not the last one (Sorted DESC). So, I assume that the Sort is not working properly.
Any idea? Is it a bug?
Tags for this Thread