Autocompeter.com

02 April 2015   8 comments   Go, Javascript

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

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

Previous:
Bye bye httpretty. Welcome back good old mock! 19 March 2015
Next:
Autocompeter 1.1.8 and smooth typing 06 April 2015
Related by Keyword:
A darn good search filter function in JavaScript 12 September 2018
How to throttle AND debounce an autocomplete input in React 01 March 2018
Fastest *local* cache backend possible for Django 04 August 2017
Fastest Redis configuration for Django 11 May 2017
Fastest cache backend possible for Django 07 April 2017
Related by Text:
jQuery and Highslide JS 08 January 2008
I'm back! Peterbe.com has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
Ever wondered how much $87 Billion is? 04 November 2003
Guake, not Yakuake or Yeahconsole 23 January 2010