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

1,159 views
Skip to first unread message

Sampath Lokuge

unread,
Sep 16, 2021, 10:32:39 AM9/16/21
to Firebase Google Group
Hi,

@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.

I have tried this:

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


And this too:

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

But still the same error as above. Any help here. Thanks!

Note: You cannot see status property. But it is there on the 3rd arrow path and the same level.

1.png


Query using AngularFire

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

      .pipe(first());
  }

Frank van Puffelen

unread,
Sep 16, 2021, 10:37:01 AM9/16/21
to Firebase Google Group
You're almost there :)

The error tells you that it needs an index on "status" at "/groups/test/leadPropertyInformations". So adding the $groupID in your second rules set was correct, but the $id isn't needed.

The correct index for that message is:

{
  "rules": {
      "groups": {
          "$groupID": {
             "leadPropertyInformations":{
                ".indexOn": ["status"]
             }
          }
       }
   }
}

Sampath Lokuge

unread,
Sep 17, 2021, 11:02:48 AM9/17/21
to Firebase Google Group
Hi Frank,

I don't know why you didn't give your feedback on my Stackoverflow question. You have replied/helped me a lot there.  Anyway thanks a lot. This is working fine.  

Reply all
Reply to author
Forward
0 new messages