URL: https://autocompeter.com/

About a year ago I found a great article about how to use Redis to index every prefix of every word as an index and thus a super fast way of building an autocomplete service. The idea is that you take all your titles and index them like this; if the title is "My Title" you store a key for m, my, t, ti, tit, titl and title. That means you can do very fast lookups as someone is typing unfinished words.

Anyway. I was running this merrily here on my personal blog but I liked it so much and I wanted to use it on aother site for work that I thought it'd be time to extract it into its own little microservice. All I needed was a name and my friend and colleague jezdez suggested I call it "autocompeter". So that it became.

The original implementation was written in Python and at the time I was learning Go and was eager to have something to build in Go. So I built this microservice in Go using the Negroni web framework.

The idea is that you own and run a website. You have a search feature on your website but you don't have a nifty autocomplete (aka. live search) thing on it. So, you send me all your titles, URLs and optionally their "popularity ranking" (basically a score). I'll index them on autocompeter.com under your domain. You have to sign in with GitHub to set up an API Auth Key.

Then, you put this into your HTML:


<script src="//cdn.jsdelivr.net/autocompeter/1/autocompeter.min.js"></script>
<script>
Autocompeter(document.querySelector('input[name="q"]');
</script>

Also, you'll need to download the CSS and put into your site. I don't recommend pointing to a CDN for CSS.

And that's all you have to do. The REST API, options for the Javascript integration and CSS integration in the documentation.

The Javascript is framework-free meaning it's just pure DOM manipulation and works in IE and modern browsers. The minified file is only 4.2Kb minified (2Kb gzipped).

All code is Open Source under a BSD license. Everything is free but there's no SLA as of yet.

I'm going to be blogging more and more about feature development, benchmarks and other curious things I learn developing this further.

Comments

Post your own comment
Ursuline Reine

I get a "No 'Access-Control-Allow-Origin' header is present on the requested resource." error :-(

What am I doing wrong?

Peter Bengtsson

What are you trying to do?

Ursuline Reine

I did the curl part, then I created a page with an input, I added the CDN link to it, and the script block too. But as soon as the input field gets focus the ping returns that error.

Seems https://autocompeter.com/v1/ping is not granting access to the request.

Thanks.

Peter Bengtsson

Strange. I'll take a look as soon as I get back to the office.

Ursuline Reine

Hi Peter,
So no news about this?
Thank you.

Ursuline Reine

Cool, thanks!

Andrea Greco

Hi, thanks for the amazing script and all. In your documents API page the example for curl is missing a \ on the first line; -curl -X POST -H "Auth-Key: yoursecurekey"

I could not work out the upload because did not noticed at first, but luckily I did give another try using the same snippet from the Usage section in autocompeter.com, now all is fine.

Thanks
Andrea

Your email will never ever be published.

Related posts