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

Issue

@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

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

JSON Tree

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

enter image description here

Query using AngularFire

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

      .pipe(first());
  }

Can you tell me what was the issue with my Rule?

Solution

You would need more placeholders in your rule to make i work:

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

Answered By – Tarik Huber

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published