在阅读了很多有关.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
答案 0 :(得分:0)
根据Hristo Eftimov的建议,我改变了存储标签的方式,以便获得更好的访问权限。我是通过为标签创建不同的表来做到这一点的,该表更易于访问并且不需要特定的索引