Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geoNear, does not return all matching elements, it returns only a max of 100 documents [DATAMONGO-1123] #2039

Closed
spring-projects-issues opened this issue Dec 17, 2014 · 3 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Dec 17, 2014

Olaf Krische opened DATAMONGO-1123 and commented

Aloha,

I have the following query:

public GeoResults<MyObject> findByTypeAndLocationNear(MyObjectType type, Point p, Distance distance) {
   final NearQuery nearQuery = NearQuery.near(p).maxDistance(distance);
   log.info("{}",nearQuery.toDBObject());
   return mongoTemplate.geoNear(nearQuery, MyObject.class);
}

The geoNear method is documented like this:

Returns {@link GeoResults} for all entities matching the given {@link NearQuery}.

I expect 1000 "matching" documents But i only get 100. There is some default being set, that restricts the result to 100. That should be stated in the method. And another method having a pageable should be added.

What do you think?


Affects: 1.6.1 (Evans SR1)

Backported to: 1.6.2 (Evans SR2), 1.5.5 (Dijkstra SR5)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 18, 2014

Oliver Drotbohm commented

That's MongoDB's default behavior clearly documented here. To set this to a different value, use NearQuery.num(…)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 18, 2014

Olaf Krische commented

Yes, you are right. But i look at the library documentation. And there it says "all entities". Its like offering "findAll", but forgetting to mention, that you actually need paging to get "all". Just saying, that i ran into this and i didnt expect this behaviour

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 7, 2015

Oliver Drotbohm commented

I've added a note to the JavaDoc. It's vague by purpose as I want to avoid replicating fine-grained details of the way MongoDB implements what

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants