Sphinx in WordPress

Hey there! I'm currently working on a CLI tool to deploy WordPress apps to DigitalOcean. Check it out! It's free and open source.

WordPress and Sphinx Search

You probably will agree with me that the standard WordPress search doesn’t even smell like search. I mean querying the database with the simplest LIKE query and sorting the results by date isn’t really a search. I’ve been keeping my eye out on Sphinx — an open source search server that works well with MySQL databases and I’ve finally had a chance to set it up for Theme.fm.

A few hours poking around the documentation and config files, I was not only able to get search results relevant to my search query, but also get it to search by taxonomies, and my favorite — the suggest tool. As seen in the image above I missed a few letters in my search query and Sphinx was able to correct me based on a dictionary from all the words in the site’s posts and pages.

It’s incredibly fast and easy to use once the configs are right. I hadn’t done any changes on the site itself, except a call to a “suggest” function for when no results were found. The rest was handled by a plugin I wrote that filters the native WordPress search. So I’m now thinking of a full-blown Sphinx plugin I could write that would generate Sphinx configs on the fly, build indexes and of course replace the standard search. Thoughts?

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

4 comments