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

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

问题描述

我目前正在评估应作为移动应用程序后端的数据库.

<小时>

现在我正在关注 Firebase,目前我非常喜欢它.

<小时>

要求有可能获取

  1. 最受欢迎的商品
  2. 某个位置
  3. (可能在将来:另外在某个时间范围内,这将是项目的一个属性)

来自数据库.

<小时>

我很自然地偶然发现了 GeoFire,它为 Firebase 提供了基于位置的查询可能性.

不幸的是 - 至少据我所知 - 不可能通过距离以外的属性对结果进行排序.(如果我错了,请纠正我).

如果我对距离不感兴趣(我只想在某个半径范围内拥有物品,无论离中心多远),而是对流行因素(例如,为了简单起见,一个简单的代表人气的数字)?

重要提示:
在客户端进行过滤/排序不是一种选择(或至少是最不受欢迎的一种),因为结果集可能会增长到无限量.

<小时>

应用程序的第一个版本将用于 android,因此第一步将使用 Firebase Java 客户端库.

<小时>

是否有可能解决这个问题,或者 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天全站免登陆