【问题标题】:Firebase realtime .indexOnFirebase 实时 .indexOn
【发布时间】:2019-05-03 13:32:31
【问题描述】:

在阅读了很多关于 .indexOn 的内容后,我以为我理解了它是如何工作的,但似乎我对一个案例仍然有些迷茫。

我的麻烦是我在标签搜索中收到了 .indexOn 警告,如下所示:

postRef
 .orderByChild(`i/tags/${tag}/a`)
 .equalTo(1)

${tag}是被搜索的标签

我有以下结构:

还有规则:

"posts": {
      ".read": "auth != null",
      ".write": "auth != null",
      ".indexOn": "i/ts",
      "$pid": {
        "i": {
          "tags": {
            ".indexOn": "a",
          },
        }
      }
    },

据我了解,我的通配符应该适用于 postId 并且 .indexOn 应该适用于这种情况,但我在每次搜索时都会收到警告

我得到的警告是:

[Firebase/Database][I-RDB034028] Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "i/tags/test/a" at /posts to your security rules for better performance

【问题讨论】:

  • 请查看以下帖子 - stackoverflow.com/q/39238374/2765346。我想在这里你会找到答案:)
  • 你收到了什么警告?
  • @tuledev 我刚刚添加了我收到的警告
  • 我猜是这样... Frank van Puffelen,我发给你的答案的作者,是 Firebase 的一名工程师,他提供这是一个解决方案。不幸的是,我找不到这个问题的另一种解决方案,也找不到任何描述为什么这是不可能的。我也遇到了同样的深度动态密钥,我不得不更改数据模型。
  • @tuledev 不确定您在说什么,但我更改了代码以创建一个专门用于标签的表格,即使需要更多空间也更容易

标签: firebase react-native indexing


【解决方案1】:

根据 Hristo Eftimov 的建议,我更改了存储标签的方式,以便更好地访问。我通过为更易于访问且不需要特定索引的标签创建不同的表来做到这一点

Firebase .indexOn dynamic keys

【讨论】:

    猜你喜欢
    • 2017-01-07
    • 2018-12-14
    • 1970-01-01
    • 2017-07-19
    • 1970-01-01
    • 2018-03-04
    • 2016-11-09
    • 1970-01-01
    • 2016-09-29
    相关资源
    最近更新 更多