GeoFire-Android icon indicating copy to clipboard operation
GeoFire-Android copied to clipboard

.whereNearTo working only if collection has a limited number of items

Open ferakles-dev opened this issue 5 years ago • 0 comments

Testing the library: when querying a collection that contains 20 documents, the query returns the expected results. However, in case of big collections (>10k documents), the query is not returning the expected results. For example, I have around 30 documents within the radius of 1 km, and around 10000 documents outside such a radius. When querying documents within a radius of 1 km and a limit of 30 documents:

QueryLocation queryLocation = QueryLocation.fromDegrees(location.getLatitude(), location.getLongitude());
Distance searchDistance = new Distance(1, DistanceUnit.KILOMETERS);

geoFireQuery = geoFire.query()
	.whereNearTo(queryLocation, searchDistance)
	.limit(30)
	.build();

the first 28 results have a distance of 900 m - 10 km, and the remaining 2 have a distance of 129.5 km. 90% of the documents within radius of 1 km are not returned unfortunately.

If I remove the limit, the query returns 1100 documents... Of course most of them are well outside the radius. For information, I inserted the geoFireLocation field in each document via Javascript, using the formula: degreeMatch = (latitude+90)*180 + longitude;

ferakles-dev avatar Apr 01 '20 16:04 ferakles-dev