Firebase/GeoFire - Most popular item at location

寵の児 提交于 2019-12-01 12:48:58

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/39953512/firebase-geofire-most-popular-item-at-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!