The video tied to this article

Have you ever used the default search function of WordPress? Have you searched something on your own website using the search form?

And how did you like it? Did you find relevant results were sorted on top? And did it accept typos? I bet that you’re not always satisfied with how the search results came out.

Moreover, if you are a developer and have been working with websites with thousands of articles, you may found WordPress search a little slow. Especially if you are using something like live search.

Now, there are a couple of plugins such as SearchWP and Relevanssi. These plugins make search results on your WordPress website more relevant, but not necessarily more performant.

Fortunately, there is also a server-side solution which is great, called ElasticSearch. You can pair it with WordPress using a plugin. So let’s see what ElasticSearch actually is and how it can put WordPress search on steriods.

What is Elasticsearch

According to their own description, Elasticsearch is a distributes, RESTful search and analytics engine capable of solving a growing number of use cases. That is quite a mouthful. But, in essence, Elasticsearch stores your data and makes it accessible to any kind of search action.

For example, it may search through a certain term appearing in the text. Additionally, it may also look into geographical data or chronological data. It may even combine several search data to uncover new patterns. And Elasticsearch is fast. This is especially useful if you need to search in large sets of data.

Why Elasticsearch is such a deal for WordPress

WordPress Search Results with ElasticPress
Elasticsearch handling spelling mistakes.

So, why should I use Elasticsearch on WordPress then? Why is it such a deal? There are plenty of use cases.

  • Sorting search results by their relevancy
  • Accepting spelling mistakes in search terms, while still giving relevant results.
  • Searching within custom metadata, taxonomies, categories and other data tied to a post. The default WordPress search only searches through the post content and the post titles.
  • Drastic performance improvements compared to the normal WordPress search. Elasticsearch has no problem with thousands of posts or products. This also lowers the drain on server resources, which in turn may lower costs for large sites.
  • Suggesting search terms to users. Remember how Google gives you hints on how to complete your search request? This exact feature is possible with Elasticsearch, on your own WordPress website.
  • At last, rendering related posts using a simple function.

Having considered these points, you may notice that Elasticsearch is especially useful for bigger websites and webshops. It is also particularly useful for building live-search and custom filters. Examples are web shop catalogue pages with price and category filters or directory listings with geographical information.

Implementing Elasticsearch in WordPress with ElasticPress

Implementing Elasticsearch in WordPress is easy. The fine people at 10up made a plugin specifically for this, named ElasticPress.

There is one caveat however: your hosting party should support it. Cloudways supports Elasticsearch out of the box (besides having amazing performance and other features). It just needs to be turned on from their interface and you are done. If you are using another hosting party, you may want to contact them for the possibilities.

Enabling Elasticsearch in Cloudways User Interface
Enabling Elasticsearch in Cloudways

If you’re familiar with server administration, you can also install ElasticPress on your own server. There is plenty of documentation on the website of Elasticsearch.

The ElasticPress plugin in the Plugins Section of WordPress
The ElasticPress plugin in the Plugins Section of WordPress

After you have enabled Elasticsearch from a hosting perspective, you need to install the plugin from the WordPress plugin repository.

Setting up the ElasticPress host
Setting up the ElasticPress host

Subsequently, you need to provide the address for the Elasticsearch host at the plugin settings. Usually, this is 127.0.0.1:9200.

The ElasticPress settings for WordPress

After you have set up the Elasticsearch host, you can alter the settings for Elasticsearch and WordPress.

Congratulations! Now you are done. The powers of Elasticsearch are available for your WordPress website. The world of better search is at your fingertips.