Firebase 警告:使用未指定的索引。您的数据将在客户端下载和过滤

FIREBASE WARNING: Using an unspecified index. Your data will be downloaded and filtered on the client

@firebase/database: FIREBASE WARNING: Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "status" at /groups/test/leadPropertyInformations to your security rules for better performance.

Firebase RTD 规则

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null",
      "groups": {
      ".indexOn": ["leadPropertyInformations/status"]
    }
  }
}

JSON 树

注意:您看不到status属性。但是它在第三个箭头路径上。

查询使用 AngularFire

getActiveLeadPropertyInformations(): Observable<LeadPropertyInformationModel[]> {
    return this.angularFireDatabase
      .list<LeadPropertyInformationModel>(
        `groups/${this.groupId}/leadPropertyInformations`,
        (ref) => ref.orderByChild('status').equalTo('active')
      )
      .valueChanges()

      .pipe(first());
  }

你能告诉我我的规则有什么问题吗?

您的规则中需要更多占位符才能使 i 起作用:

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null",
      "groups": {
          "$groupId": {
             "leadPropertyInformations":{
               
          ".indexOn": ["status"]
         
        }
       }
      }
  }
}

路径不正确(至少不是问题中描述的那样)

您的索引是

leadPropertyInformations/status 

路径实际上是

leadPropertyInformations/22611/status

注意路径中的 22611 - 这意味着您需要添加一些内容来表示子节点,例如 $an_id 以引用问题中显示的子节点。