Skip to content

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

@ferakles-dev

Description

@ferakles-dev

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions