Using an unspecified index. Consider adding ".indexOn": "g"

18,608

Removing the brackets around ["g"] fixes the problem. Here is the final piece of code:

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

Related videos on Youtube

jshah
Author by

jshah

Updated on June 25, 2022

Comments

  • jshah
    jshah about 2 years

    I'm using Geofire to do a circleQuery in a certain area. With my observers set up I am getting back locations, however, with the location I also get back a "Using an unspecified index. Consider adding ".indexOn": "g""

    My db for my geofire looks like this karmadots/geofire/{events}

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

    I've also tried:

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

    Both don't make the message go away. Is there something else I can try reading or try as an example?

    Thanks for the help.

    EDIT:

    My path is xxxxx.firebaseio.com/karmadots/geofire/{keys}

    This is how I query:

    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")
        })
    
    }
    
    • Frank van Puffelen
      Frank van Puffelen over 9 years
      The latter looks more likely to be correct. But just to be sure, can you show us the query you run? Preferably showing the entire path from root to the actual events used in the geofire query.
    • jshah
      jshah over 9 years
      @FrankvanPuffelen I've edited my original post and included the query. Not sure if thats what you meant by my entire path.
    • Frank van Puffelen
      Frank van Puffelen over 9 years
      Hmm... when I run a regular Firebase query on it, I get no errors: new Firebase('https://karmadots.firebaseio.com/karmadots/geofire‌​/').orderByChild('g'‌​).startAt("9q8yywcp3‌​9").endAt("9q8yywcp3‌​9").limitToFirst(3).‌​once('value', function(s) { console.log(s.val()); }). That is essentially what GeoFire does too.
    • jshah
      jshah over 9 years
      Does the order by child happen under the karmadots/geofire path? Isnt there one more directory before you can order by g i.e. karmadots/geofire/{keys}/g. Secondly, is my query adding the orderByChild()? Or is that added by the .indexOn?
    • jshah
      jshah over 9 years
      When I removed the brackets from ".indexOn": ["g"] and just used ".indexOn" : "g", it worked.
    • Frank van Puffelen
      Frank van Puffelen over 9 years
      OK, perfect. Can you post it as an answer and accept it?
    • jshah
      jshah over 9 years
      Yes, will do. Thanks
  • Mike Axle
    Mike Axle almost 7 years
    this is the only working answer i could find. thanks!
  • Admin
    Admin over 6 years
    The log message quoted in the OP has the correct syntax - not sure how the brackets got involved.