Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 使用未指定的索引。考虑添加“。“indexOn”一词:&引用;g";_Firebase_Firebase Security - Fatal编程技术网

Firebase 使用未指定的索引。考虑添加“。“indexOn”一词:&引用;g";

Firebase 使用未指定的索引。考虑添加“。“indexOn”一词:&引用;g";,firebase,firebase-security,Firebase,Firebase Security,我正在使用Geofire在某个区域进行循环查询。随着我的观察者的设置,我回到了位置,但是,在这个位置,我也得到了一个“使用一个未指定的索引。考虑添加”。 我的geofire数据库看起来像是karmadots/geofire/{events} "rules": { "karmadots": { ".read": true, ".write": true, "geofire": { "$events": { ".indexOn": ["g"]

我正在使用Geofire在某个区域进行循环查询。随着我的观察者的设置,我回到了位置,但是,在这个位置,我也得到了一个“使用一个未指定的索引。考虑添加”。 我的geofire数据库看起来像是karmadots/geofire/{events}

"rules": {
  "karmadots": {
    ".read": true,
    ".write": true, 
    "geofire": {
      "$events": {
        ".indexOn": ["g"]
      }
    }   
  }
我也试过:

"rules": {
  "karmadots": {
    ".read": true,
    ".write": true,
    "geofire": {
      ".indexOn": ["g"]
    } 
  }
}
两者都不能使信息消失。还有什么我可以尝试阅读或尝试的例子吗

谢谢你的帮助

编辑:

我的路径是xxxxx.firebaseio.com/karmadots/geofire/{keys}

我是这样问的:

func setupListeners(query: GFQuery){

    // Event is in initial area or entered area
    query.observeEventType(GFEventTypeKeyEntered, withBlock: { (key: String!, location: CLLocation!) in
        println("Key '\(key)' entered the search area and is at location '\(location)'\n")
    })

    // Event left area
    query.observeEventType(GFEventTypeKeyExited, withBlock: { (key: String!, location: CLLocation!) in
        println("Key '\(key)' left the search area\n")
    })

    // Event moved but is still in area
    query.observeEventType(GFEventTypeKeyMoved, withBlock: { (key: String!, location: CLLocation!) in
        println("Key '\(key)' moved in the search area and is at location '\(location)'\n")
    })

}

移除[“g”]周围的括号修复了该问题。下面是最后一段代码:

"rules": {
  "karmadots": {
    ".read": true,
    ".write": true,
    "geofire": {
      ".indexOn": "g"
    } 
  }
}

后者看起来更可能是正确的。但是为了确定,您可以向我们展示您运行的查询吗?最好显示从根目录到geofire查询中使用的实际事件的整个路径。@FrankvanPuffelen我已经编辑了我的原始帖子并包含了查询。我不确定你说的我的整个道路是否就是这个意思。嗯。。。当我对它运行常规Firebase查询时,我没有得到任何错误:
newFirebase('https://karmadots.firebaseio.com/karmadots/geofire/.orderByChild('g').startAt(“9q8yywcp39”).endAt(“9q8yywcp39”).limitToFirst(3).once('value',函数{console.log(s.val());})
。这本质上也是GeoFire所做的。孩子们的命令是否发生在karmadots/GeoFire路径下?在您可以按g排序之前,是否还有一个目录,即karmadots/geofire/{keys}/g。其次,我的查询是否正在添加orderByChild()?或者这是由.indexOn添加的?当我从“.indexOn:[“g”]中删除括号并刚刚使用“.indexOn:“g”时,它起了作用。这是我能找到的唯一有效答案。谢谢OP中引用的日志消息具有正确的语法-不确定括号是如何涉及的。