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

时间:2015-01-21 05:12:36

标签: firebase firebase-security

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

我的地理位置数据库看起来像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")
    })

}

1 个答案:

答案 0 :(得分:37)

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

"rules": {
  "karmadots": {
    ".read": true,
    ".write": true,
    "geofire": {
      ".indexOn": "g"
    } 
  }
}
相关问题