Q: Spring-data mongodb geo query I am using spring-data to communicate with mongodb,I am looking for a way to perform geo query which will retrieve near by profiles by given geo point from DB, my requirements from the query  are:
1) limit by distance 
2) limit by number of returned profiles 
3) additional search according time field in the profiles document
4) the ability to include / exclude fields from the retrieved documents
At first I used mongoTemplate.geoNear method...
   Query criteria = new Query(Criteria.where("time").gte("some_date")); 
   criteria.fields().exclude("friends");
    NearQuery query = NearQuery.near(point).maxDistance(maxDistance)
            .num(limit).query(criteria);
    GeoResults<Profile> result = mongoTemplate
            .geoNear(query, Profile.class);<br/>

But then I realized that mongo does not support in including/excluding fields in geoNear queries.
So I am thinking about Near query, it seems that the only way to perform that kind of "complex" query in spring-data is by using @Query annotation,is there a way to support requirements 2,3 above in that kind of query? any other way ?
Thanks

A: You question actually features the pieces to all of the answer you need. You only need to use query.addCriteria to put them all together.
1: Use a Circle with a radius
2. Use Query.limit(count)
3. Use the Query.where("date").gte()
4. Use fields to project results
Here you go
    Point point = new Point(6.12343, 3.121211);
    Distance distance = new Distance(100, Metrics.KILOMETERS);
    Circle circle = new Circle(point, distance);
    Integer resultLimit = 20; //Limit to 20 records
    Criteria geoCriteria = Criteria.where("position").withinSphere(circle);
    Criteria timeCriteria = Criteria.where("time").gte(new Date());
    Query query = Query.query(geoCriteria);
    query.addCriteria(timeCriteria);
    query.fields().exclude("friends");
    mongoTemplate.find(query, Profile.class);

