I've found Apache Solr the best approach to building a flexible, fast auto-complete service. Solr can spit results back in json so it's dead easy to write a simple API wrapper in whatever language you're using (go, python, ruby).<p>You can then stick Varnish in front of the whole lot if the search space is relatively static and not ridiculously huge.
Consider using package `log` for logging, `fmt.Printf` doesn't linearize writes to stdout.<p><a href="https://github.com/peterbe/autocompeter/blob/master/server.go#L134" rel="nofollow">https://github.com/peterbe/autocompeter/blob/master/server.g...</a><p>Also with `log` you don't need to add a `\n` at the end, it will do it for you.
Clever name, Peter. :)<p>Btw, I noticed a missing "c" in the "url -X POST" example on this page of your docs:<p><a href="http://autocompeter.readthedocs.org/en/latest/api/#bulk-upload" rel="nofollow">http://autocompeter.readthedocs.org/en/latest/api/#bulk-uplo...</a>
I blogged about it here: <a href="http://www.peterbe.com/plog/autocompeter.com" rel="nofollow">http://www.peterbe.com/plog/autocompeter.com</a>
Meh, it's a decent and properly commented implementation, but the interesting stuff is done by Redis, not in Go.<p>I wrote a similar service (JS+Go) 2 years or so ago using only the Go standard library (specifically the excellent index/suffixarray and gobs for persistence). It typically got ~3ms response timings (locally) with > 1 million records indexed.
I put together an autocomplete service using Ruby and Redis but rather than dealing with the network latency of a remote service I decided to package it up so it could be mounted along side my app: <a href="https://github.com/doomspork/autocomplete-me" rel="nofollow">https://github.com/doomspork/autocomplete-me</a>
Comments:<p>1. The focus should be on the search box when the page is loaded.<p>2. While typing the word "javascript", sometimes the amount of results shrinks and immediately increases, resulting in flickery behavior.