I added searching capabilities to this static website. I don’t think any website is useful these days without some basic search functionality.

I created a Jekyll plugin that will go through the posts and pages, and index them in elasticsearch. You can find the source code for the indexer plugin on my GitHub account. Right now it indexes all of the documents (posts and pages) each time the website is generated – the whole process is about 7 seconds each.

I will eventually have to check the last modified date on the document files, and only index the ones that are either 1) new or 2) have been modified since last indexed.

BTW, my elasticsearch index settings (including mapping) can be viewed here – this is for the jaysoo index, with only one type (page).

I implemented a simple search service using node.js, which will perform faceted queries against elasticsearch. The results are returned in JSON format (unchanged from elasticsearc’s response). You can view my node.js server code by view the Gist

On the front-end, I am using visualsearch.js, which is an excellent library from DocumentCloud (same company that made Backbone.js and Underscore.js). It provide the ability to do faceted searches from a sinle search box.

The result is a JavaScript driven (both front-end and backend) search page. Unfortunately, the search page will not work unless you have JavaScript enabled. I think that’s okay, at least for the time being.

blog comments powered by Disqus