Elasticsearch for WordPress – an ElasticPress tutorial
Gijs Hovens, January 17, 2019
Elasticsearch is a search technology that processes search queries extremely quickly and is great at determining the most relevant results. With the Savvii Elasticsearch package, you will equip your website with the power of Elasticsearch.
Will Elasticsearch improve your WordPress site?
An Elasticsearch integration improves more than just your website’s search functionality. It speeds up your website’s search functionality, provides more relevant results, and improves your website wherever WP_Query is used in the code. Even if you don’t use a search field in your front end, the WP_Query function will still be used in lots of places.
Category and tag pages, archive pages, post and overview pages in your wp-admin, or custom taxonomies: Elasticsearch will speed all of these up. This means that Elasticsearch will also help if you have a slow back end, for example.
Ask yourself the following questions to determine if Elasticsearch is right for your website:
How do users navigate my website?
View a web analytics package like Google Analytics or the HotJar heatmaps, for example, to see how users navigate your website. Are they using the search function? Are they using filters? Are they navigating through category, tag, author, or archive pages? Are they sorting lists containing items or products? All of these things use the WP_Query function and will be sped up and improved with an Elasticsearch integration.
Research done by Swedish conversion optimization agency Conversionista shows that site searchers convert 90% more than non site searchers.
Measuring and improving your search functionality should be an absolute priority if you see that your search function is being used often. Even more so if you are using an e-commerce solution such as WooCommerce.
What are the slowest pages on my WordPress site?
In the Google Analytics page timing report, you can see which pages are slow and which are fast. If you see the search results, category, tag, author, and archive pages at the bottom of the list of slow pages, your website will become much faster by integrating Elasticsearch.
Akamai, among others, has done research showing that slow pages are real conversion killers.
A 100-millisecond delay in website load time can hurt conversion rates by 7 percent
Am I experiencing a slow WP-admin?
You don’t need analytics to figure this out. You will know if it is frustrating to work in your WP-admin due to pages that are slow to load or slow searches for posts or WooCommerce orders. It is mainly the search queries for orders, pages and posts, and the overview pages for posts, pages and products that will become much faster with Elasticsearch.
Do the questions above show you that you need to improve your search functionality? Then you should follow our Elasticsearch with ElasticPress tutorial and improve your WordPress site’s conversion.
Step 1: Make sure you have an Elasticsearch host
We will assume that you already have a WordPress site. In addition to hosting for your WordPress and your site itself, you will also need an Elasticsearch application that is hosted somewhere. It is possible to install and maintain Elasticsearch on a VPS yourself. Would you prefer to focus on your website? Then we advise that you order a Savvii Elasticsearch package (our competitive prices are exclusively for Savvii customers).
Step 2: Install the ElasticPress plugin
The best way to link your WordPress site to your Elasticsearch host is by using the ElasticPress plugin by a company called 10up. 10up not only provides this plugin, but the Savvii Elasticsearch hosts are also provided by 10up.
Step 3: Configure the ElasticPress plugin
The first step is to enter your Elasticsearch host in the plugin. The plugin will immediately recognize the ElasticPress and Savvii host (as the endpoint in the plugin). You will then be asked for:
- Subscription ID
- Subscription Username
You will find this data in your ElasticPress account under ‘My Subscription’. Do you have an Elastic package with Savvii? Then we have already entered this for you.
After you have entered all the credentials, click ‘Save Changes’.
The next step is to synchronize all of your content with the ElasticPress host. To do this, click on the ‘sync’ icon on the top right in the plugin.
Now, go to the settings page in the ElasticPress plugin.
Of course, you will want to set this to ‘enabled’, otherwise Elasticsearch will not be used on your site. The second setting provides you with the possibility to weigh more recent content more heavily in the search results. Whether or not this is a good idea depends on your content.
To take full advantage of Elasticsearch, we recommend that you set this to ‘enabled’. This way you will also find drafts and private content in your wp-admin faster. Make sure your host is not publicly accessible if you enable this setting. You won’t have to worry about this with Savvii and ElasticPress hosts.
Using this, the content in your ppt, pptx, doc, docx, xls, xlsx, and pdf files will also be indexed. These must have been uploaded to your media library through WordPress. ElasticPress will not scan files on your server. Think about whether you want to index these or if you just want to index posts and pages that link to these files.
Facets are filters. These filters are applied to your content (not to your products, see WooCommerce for that). Using this option, it will be possible for users to filter certain taxonomies on your site. Examples of taxonomies are a category or a tag. You can also add new taxonomies yourself.
You can also choose to show results that meet one of the chosen criteria or only results that meet all the criteria.
After you have enabled facets, you will need to add these to your website using a widget. You can find widgets under ‘Display’ > ‘Widgets’.
Another extra function that you can add to your website using ElasticPress is ‘Related Posts’. There are multiple plugins that do this, but they often make your site very slow. That is not the case with the ElasticPress related posts. You also have to enable these, and add them to your site using a widget.
This option is only available if your WordPress website has an active WooCommerce plugin. This option is actually the same as facets, but for products.
You will have seen it on big websites like Amazon, where you can filter price categories, reviews, colour, material, and more. That makes this option is perfect for webshops! In addition to turning facets on and off, here you can indicate if the selection has to meet all checked filters. For example, both ’50-100 euros’ and ‘5-star rating’ or just one of the filters (for example ’50-100 euros’ or ‘5-star rating’).
You only have to enable this option, you don’t have to add it using a widget.
We definitely recommend this option. By using Autosuggest, your users will receive content suggestions while they are typing their search query. Oftentimes this will save them having to click through to the search results page. This way they will find what they are looking for faster, and that will contribute to an improved conversion rate for your website!
Step 4: Test your implementation
After you have set up ElasticPress, go to your website’s front end. Of course, you will check if the facets, related posts, and Autosuggest you set up are visible here. It is also a good idea to check two other things: the headers on your search results page, and the console on your search results page. You can use your browser’s developer tools to check both of these.
If ElasticPress works properly, the header will display:
in the response header of your search results page. Check the console for any error messages as well.
Are you not seeing anything in the headers and the console, and is ElasticPress still not working as you expect? Then perform a new synchronization first and test again.
Do you also want to make your website faster?
Order a Savvii Elasticsearch package! Do you already have an Elasticsearch package elsewhere? Then read our ultimate checklist to make your WordPress website even faster.