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);
});
});
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);
});
});
Share
Improve this question
edited Oct 15, 2017 at 19:53
Saeed Heidarizarei
asked Oct 15, 2017 at 11:56
Saeed HeidarizareiSaeed Heidarizarei
8,91622 gold badges66 silver badges111 bronze badges
1 Answer
Reset to default 13You 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.