I have users
collection in Firestore each document of which has the format { d: <obj>, g: <str: geohash>, l: <GeoPoint> }
, and I use geofirestore-js on my client app to perform a Nearby Search, and it's been working great.
However, I wonder if geofirestore-js retrieves all the documents from users
beforehand behind the scenes, and performs the calculation to narrow down the result.
The reason I'm asking is that, according to Firebase official document, it is NOT the number of API calls, but number of documents which counts.
Or, does the library magically narrow down the result on the server side?
It does not read all the documents. That wouldn't scale at all. Geo queries use a special encoding that can be efficiently queried to find only the documents that match.
It even says on the GitHub page:
GeoFirestore selectively loads only the data near certain locations, keeping your applications light and responsive, even with extremely large datasets.