使用未指定的索引.考虑添加".indexOn":"g"

jsh*_*hah 21 firebase firebase-security

我正在使用Geofire在某个区域进行circleQuery.随着我的观察员的设置,我回到了位置,但是,我找回了一个位置"使用未指定的索引.考虑添加".indexOn":"g""

我的地理位置数据库看起来像karmadots/geofire/{events}

"rules": {
  "karmadots": {
    ".read": true,
    ".write": true, 
    "geofire": {
      "$events": {
        ".indexOn": ["g"]
      }
    }   
  }
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

"rules": {
  "karmadots": {
    ".read": true,
    ".write": true,
    "geofire": {
      ".indexOn": ["g"]
    } 
  }
}
Run Code Online (Sandbox Code Playgroud)

两者都不会消息消失.还有什么我可以尝试阅读或尝试作为一个例子吗?

谢谢您的帮助.

编辑:

我的路径是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")
    })

}
Run Code Online (Sandbox Code Playgroud)

jsh*_*hah 39

删除["g"]周围的括号可解决问题.这是最后一段代码:

"rules": {
  "karmadots": {
    ".read": true,
    ".write": true,
    "geofire": {
      ".indexOn": "g"
    } 
  }
}
Run Code Online (Sandbox Code Playgroud)