Mark Harrop
Mark Harrop

Reputation: 202

Using an unspecified index. Your data will be downloaded and filtered on the client. even though ive added .indexOn

trying to fix a bug on firebase database.

ive got nodes set up like this

 "Apps":{
  "Booster": {
"ANTBOOSTER": {
  "desc": "",
  "downloads": 30,
  "image": "",
  "tag": "",
  "title": "",
  "upvote": 50,
  "url": ""
}
  },
  "MoviesnShows": {
"BeeTv": {
  "H20": true,
  "desc": "",
  "downloads": 11,
  "image": "",
  "tag": "",
  "title": "Bee Tv",
  "upvote": 1,
  "url": ""
},

app side im getting this error

Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "upvote"' at Apps/Booster to your security and Firebase Database rules for better performance

this is for every parent node ie Booster, MoviesnShows. its giving the error for upvote and downloads children.

so ive been reading the documentation from firebase and it says about adding the rule .indexOn to my rules section. which ive done like this.

"Apps":{
  "MoviesnShows":{
       ".indexOn":["downloads","upvote","H20"],
    
     "Booster":{
       ".indexOn":["downloads","upvote","H20"],

but for some reason its only clears the error for the first rule which in this case is MoviesnShows. if i switch them around it clears Booster. im again obvioulsy missing something can anybody tell me what?

Upvotes: 2

Views: 98

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599521

Your nesting of the rules is off. Since you never close the { that is after MoviesnShows, your rules for Booster are at path Apps/MoviesnShows/Booster.

To fix this, close the MoviesnShows node with }:

"Apps": {
  "MoviesnShows": {
    ".indexOn":["downloads","upvote","H20"]
  },
  "Booster":{
    ".indexOn":["downloads","upvote","H20"]
  }
}

If you have more nodes like MoviesnShows and Booster, you can consider using a wildcard capture rule to define the indexes for all of them in one go:

"Apps": {
  "$topic": {
    ".indexOn":["downloads","upvote","H20"]
  }
}

Upvotes: 2

Related Questions