0

I am currently in the evaluation process for a database that should serve as a backend for a mobile application.


Right now I am looking at Firebase, and for now I like it really much.


It is a requirement to have the possibility to fetch the

  1. most popular items
  2. at a certain location
  3. (possibly in the future: additionally for a certain time range that would be an attribute of the item)

from the database.


So naturally I stumbled upon GeoFire that provides location based query possibilities for Firebase.

Unfortunately - at least as far as I understood - there is no possibility to order the results by an attribute other than the distance. (correct me if I am wrong).

So what do I do if I am not interested in the distance (I only want to have items in a certain radius, no matter how far from the center) but in the popularity factor (e.g. for the sake of simplicity a simple number that symbolizes popularity)?

IMPORTANT:
Filtering/Sorting on the client-side is not an option (or at least the least preferred one), as the result set could potentially grow to an infinite amount.


First version of the application will be for android, so the Firebase Java Client Library would be used in the first step.


Are there possibilities to solve this or is Firebase out of the race and not the right candidate for the job?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
JDC
  • 4,247
  • 5
  • 31
  • 74
  • There is no way to add an extra condition to the server-side query of Geofire. Well... strictly speaking you could find a way to extend the magic of Geohashes to add a third number (in addition to lat and lon) into the mix. But while possible, I doubt it's feasible for most of us. – Frank van Puffelen Oct 10 '16 at 09:02
  • Ok, thank you for the quick response. Thats sad, I would have really liked to use Firebase as a backend, but this query unfortunately is crucial. I will see if I still find another solution (e.g. use an intermediate server that does the heavy stuff before sending the answer to a client request for those special use cases). – JDC Oct 10 '16 at 09:58

1 Answers1

0

There is no way to add an extra condition to the server-side query of Geofire.

The query model of the Firebase database allows filtering only on a single property. Geofire already performs a seemingly impossible feat of filtering on both latitude and longitude. It does this through the magic of Geohashes, which combine latitude and longitude into a single string.

Strictly speaking you could find a way to extend the magic of Geohashes to add a third number into the mix. But while possible, I doubt it's feasible for most of us.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807