How to query closest GeoPoints in a collection in Firebase Cloud Firestore?

We haven't exposed geoqueries yet, so currently there isn't a way to do this.

Historically, the Firebase Realtime Database used geohashes in a library called GeoFire--but given that we plan to expose actual geoqueries in the near future, we haven't updated that library to Firestore. To learn how to do something similar yourself though, have a look at this video.


A new project has been introduced since @problemsofsumit first ask this question. The project is called GEOFirestore.

With this library you can perform queries like query documents within a circle:

  const geoQuery = geoFirestore.query({
    center: new firebase.firestore.GeoPoint(10.38, 2.41),
    radius: 10.5
  });

You can install GeoFirestore via npm. You will have to install Firebase separately (because it is a peer dependency to GeoFirestore):

$ npm install geofirestore firebase --save

You can link to it via cdn: https://cdn.jsdelivr.net/npm/[email protected]/dist/geofirestore.min.js


You could let Algolia do the geo search with radius for you. All it would require is to build a cloud function that triggers on your wanted documents and sync them to Algolia.

Take a look at Geo Search https://www.algolia.com/doc/guides/searching/geo-search/

Also Firebase documentation advertises Algolia as a solution to complex searches here https://firebase.google.com/docs/firestore/solutions/search