title: Autocomplete with Firebase
body: <p>How does one use Firebase to do basic auto-completion/text preview?</p>
  
  <p>For example, imagine a blog backed by Firebase where the blogger can tag posts with tags. As the blogger is tagging a new post, it would be helpful if they could see all currently-existing tags that matched the first few keystrokes they've entered. So if "blog," "black,"  "blazing saddles," and "bulldogs" were tags, if the user types "bl" they get the first three but not "bulldogs." </p>
  
  <p>My initial thought was that we could set the tag with the priority of the tag, and use startAt, such that our query would look something like:</p>
  
  <pre><code>fb.child('tags').startAt('bl').limitToFirst(5).once('value', function(snap) {
    console.log(snap.val()) 
  });
  </code></pre>
  
  <p>But this would also return "bulldog" as one of the results (not the end of the world, but not the best either). Using startAt('bl').endAt('bl') returns no results. Is there another way to accomplish this?</p>
  
  <p>(I know that one option is that this is something we could use a search server, like ElasticSearch, for -- see <a href="https://www.firebase.com/blog/2014-01-02-queries-part-two.html" rel="noreferrer">https://www.firebase.com/blog/2014-01-02-queries-part-two.html</a> -- but I'd love to keep as much in Firebase as possible.)</p>
  
  <p><strong>Edit</strong></p>
  
  <p>As Kato suggested, here's a concrete example. We have 20,000 users, with their names stored as such:</p>
  
  <pre><code>/users/$userId/name
  </code></pre>
  
  <p>Oftentimes, users will be looking up another user by name. As a user is looking up their buddy, we'd like a drop-down to populate a list of users whose names start with the letters that the searcher has inputted. So if I typed in "Ja" I would expect to see "Jake Heller," "jake gyllenhaal," "Jack Donaghy," etc. in the drop-down. </p>