Jan 30th, 2012, 09:18 AM
spring data mongoDB geo-queries
I've been working on spring data mongoDb 1.0.0-RELEASE, I have some geo queries that retrieves documents on tow conditions
the first one is creation date must be in last 24 hours and the second is the near the user location
so my query is like this:
new Query(Criteria.where(dtCreated).gte(new Date(System.currentTimeMillis() - 24*3600)).and(location).nearSphere(new Point(longitude, latitude)) .maxDistance(
new Distance(radius, Metrics.MILES)
this query returned only by date not considering location and extremely beyond max distance:
and I couldn't solve it any way other than using the and operator method and adding a less than condition on date, then adding the geo condition and method.
if any one knows why this is happening please reply.
Tags for this Thread