最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "Keyboards&

programmeradmin3浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 13

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论