title: Firebase .indexOn with complex DB structure
body: <p>The current query you see below is not efficient because I have not setup the proper indexing. I get the suggestion <code>Consider adding ".indexOn": "users/kxSWLGDxpYgNQNFd3Q5WdoC9XFk2" at /conversations</code> in the console in Xcode. I have tried it an it works. </p>
  
  <p>However, I need the user id after <code>users/</code> to be dynamic. I've added a link to another post below that has tried a similar thing, but I just can't seem to get it. All help would be much appreciated! </p>
  
  <p>Note: The console output user id above does not match the screenshot below, but does not matter to solve the problem I believe. Correct me if I'm wrong. Thanks!</p>
  
  <p>Here is the structure of my DB in Firebase: </p>
  
  <pre><code>{
    "conversationsMessagesID" : "-KS3Y9dMLXfs3FE4nlm7",
    "date" : "2016-10-19 15:45:32 PDT",
    "dateAsDouble" : 4.6601793282986E8,
    "displayNames" : [ “Tester 1”, “Tester 2” ],
    "hideForUsers" : [ "SjZLsTGckoc7ZsyGV3mmwc022J93" ],
    "readByUsers" : [ "mcOK5wVZoZYlFZZICXWYr3H81az2", "SjZLsTGckoc7ZsyGV3mmwc022J93" ],
    "users" : {
      "SjZLsTGckoc7ZsyGV3mmwc022J93" : true,
      "mcOK5wVZoZYlFZZICXWYr3H81az2" : true
    }
  }
  </code></pre>
  
  <p>and the Swift query:</p>
  
  <pre><code>FIRDatabase.database().reference().child("conversations")
    .queryOrderedByChild("users/\(AppState.sharedInstance.uid!)").queryEqualToValue(true)
  </code></pre>
  
  <p><strong>Links to other post:</strong>
  <a href="https://stackoverflow.com/questions/33206932/how-to-write-indexon-for-dynamic-keys-in-firebase">How to write .indexOn for dynamic keys in firebase?</a></p>