Why I'm Getting This error?:
FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "Keyboards" at / to your security rules for better performance
I have many Telegram Keyboards in my Firebase
1: I want to Fix This Error. ✔️
2: I Want to get and Console.log rock
and rocky
when telegram user typed rock
,
const ref = db.ref('Keyboards/rock'); //keyboard 1
const ref = db.ref('Keyboards/morning'); //keyboard 2
const ref = db.ref('Keyboards/rocky'); //keyboard 3
Structure:
Rules:
{
"rules": {
".read": true,
".write": true,
"Keyboards" : {
".indexOn": "Keyboards"
}
}
}
Code:
const ref = db.ref('/');
ref.child('/').orderByChild('Keyboards').equalTo('rock').on("value", function(snapshot) {
console.log(snapshot.val());
key = snapshot.forEach(function(data) {
console.log(data.key);
});
});
You are running the same query multiple times and ordering by the same child each time: Keyboards
. Firebase is telling you that you probably want to index this search, kinda like telling the database that your are going to do this often so be prepared that I am going to do this search often.
It is explained here: Index your data
You can set up indexes under Database -> Rules in your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With