Firebase / GeoFire - 位置最受欢迎的项目 [英] Firebase/GeoFire - Most popular item at location

查看:272
本文介绍了Firebase / GeoFire - 位置最受欢迎的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






我现在正在评估一个应该作为移动应用程序后端的数据库的评估过程。现在我正在看 Firebase ,现在我非常喜欢它。这是一个要求有可能获取


  1. 最受欢迎的商品

  2. 某个位置

  3. (可能将来:另外对于特定的时间范围,将是该项目的属性)
  4. >

从数据库中删除。






所以很自然地,我偶然发现了GeoFire,它为Firebase提供了基于位置的查询可能性。不幸的是 - 至少据我所知,无法通过距离以外的属性。 (纠正我,如果我错了)。

那么我该怎么做,如果我不感兴趣的距离(我只想有一定的范围内的项目,没有离中心还有多远),但是受欢迎的因素(例如,为了简单起见,一个简单的数字,象征着人气)?

重要提示:

在客户端上的过滤/排序不是一个选项(或者至少是最不喜欢的选项),因为结果集可能会增长到无限的数量。






该应用程序的第一个版本将用于android,因此将在第一步中使用Firebase Java Client Library。






有没有可能解决这个问题呢,还是Firebase退出比赛而不是合适的人选?

没有办法给Geofire的服务器端查询添加额外的条件。

Firebase数据库的查询模型只允许在单个属性上进行过滤。 Geofire已经在经纬度上执行了一个看似不可能的滤波功能。这是通过 Geohashes 的魔术来实现的,它将经纬度合并为一个字符串。 p>

严格地说,您可以找到一种方法来扩展Geohashes的魔力,在混合中添加第三个数字。但尽管可能,但我怀疑这对大多数人是可行的。


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?

解决方案

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.

这篇关于Firebase / GeoFire - 位置最受欢迎的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆