Elasticsearch is an open-source full-text search engine. It is used to index data and search that data incredibly quickly.
In the context of WordPress, Elasticsearch can be used to speed up querying of the WordPress database. This is done by building an index of the content of your site’s database and then using Elasticsearch to search this index much more quickly than a MySQL query is capable of performing the same search.
If you have the time and ability, Elasticsearch can be integrated with a WordPress site by a highly knowledgeable WordPress and Elasticsearch developer. If your site makes relatively standard use of WP_Query, Elasticsearch can also be integrated by installing ElasticPress, a free WordPress plugin from 10up, available from WordPress.org, which automatically integrates with the WP_Query object to generate query results with Elasticsearch rather than MySQL.
Sites That Will Benefit Most from Elasticsearch
Any site that makes heavy use of WP_Query can benefit from Elasticsearch. Examples of sites that can benefit from Elasticsearch:
- Sites where search is the primary means of navigation.
- WooCommerce sites with a huge number of orders where site admins need to be able to search the list of orders regularly.
- Any site with a large number of posts where MySQL queries are producing unacceptably slow results.
If your site has queries that run unacceptably slow, or if you believe that heavy querying is overloading your site’s database, it may be a good candidate for Elasticsearch. Make sure to read our in-depth guide on WordPress search and how to speed it up.
Adding Elasticsearch to a Site at Kinsta
If you would like to add Elasticsearch to your site hosted at Kinsta, follow these steps:
- Contact Kinsta’s support team and request to have Elasticsearch added to your site.
- Kinsta’s support team will install Elasticsearch in your site container and our billing team will add the Elasticsearch add-on subscription to your account. Please note that only users with billing permissions (Company owners, Company admins, Company billing) are able to approve the addition of the add-on. The add-on is $100 a month per site. Having Elasticsearch installed on the same server as your PHP environment and MySQL database helps to decreases latency as opposed to hosting it in a separate instance or using hosted Elasticsearch from Elastic.
- Kinsta’s support team will also go ahead and install the ElasticPress plugin on your site and connect it to the Elasticpress service running in the site container.
A few features of ElasticPress include: showing WooCommerce products in search results, autocompletion of searches, choosing what you want to index, and improvements to queries for related posts. If you plan to use a different plugin or build your own integration please let our support team know and they will skip this step.
If you do opt to discontinue using Elasticsearch you may ask to have it removed from your site container and you should ask to have the add-on subscription canceled. You will receive a refund of any unused subscription fees issued according to our refund policy. Please note that only users with billing permissions (Company owners, Company admins, Company billing) are able to request removal of an add-on.
Important note if your site has both a STAGING and a LIVE environment: Elasticsearch must be installed in your STAGING and LIVE environments separately. If our support team installs Elasticsearch in one environment and then that environment is overwritten (backup restored, staging pushed live), Elasticsearch will be overwritten and removed from the container. Please plan Elastisearch installation carefully in cooperation with our support team to ensure Elasticsearch is not inadvertently removed during the setup process.
Using Elasticsearch with a WordPress Website
Once Elasticsearch has been installed it must be integrated with your site. The most common method of integrating your site with Elasticsearch is to install ElasticPress. During typical setup, our support team will install the ElasticPress plugin and connect it to the Elasticsearch service.
Following installation, you will need to access the website admin area and complete setup of the ElasticPress plugin. Part of that process is indexing the content of your site. If the content of your site is extremely large indexing via the WordPress admin may fail. You can use the ElasticPress wp-cli commands to perform indexing over SSH.
If your site makes use of custom fields and you wish to search the content of the custom fields custom development work may be required to cause ElasticPress to index and search those field.
Limits to Kinsta’s Support for Elasticsearch
Elasticsearch can accept queries passed to it locally on the server or over a RESTful API. At Kinsta, only local access to Elasticsearch is possible. Passing requests to Elasticsearch over the RESTful API is not possible and the necessary ports cannot be opened to accept these requests. If you need to pass HTTP requests to the site to be queried it will be necessary to pass the query to WordPress over the WP REST API or using an Ajax call.
We do not support or install any Elasticsearch add-on products such as Kibana or Logstash. Use of Elasticsearch on our platform is limited to integration of the service with WordPress to support faster queries.
Kinsta’s support for Elasticsearch is limited to installing Elasticsearch and any required dependencies in the site container, installing the ElasticPress plugin, and ensuring that Elasticsearch is available for use by WordPress. Integrating Elasticsearch with your website is the responsibility of each website owner and if you find that you need assistance with proper integration of Elasticsearch with your website – including the indexing and searching of custom fields – you will need to retain the services of a qualified WordPress developer.
If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans