When you run a promotional sale on your online store, you’ll see higher-than-usual traffic as visitors search for their desired products.
If you’re not prepared, your website could be in danger of lagging or even crashing due to the spike in visitors and search queries. Of course, you can recover your site easily enough if you use good managed WordPress hosting. But it’s not a great situation to be in when you’re looking to satisfy the needs of all those new customers, and retain them as well.
So how do you handle all those requests? One great option is Elasticsearch.
Though WordPress’s default search is limited in its functionalities (it doesn’t allow fuzzy search or match with categories and taxonomies), the platform is open-source, meaning a score of developers have made a significant contribution to improving the search functionality. WordPress plugins come to the rescue in order to assist this functionality. Among the broad range of search functionality, plugins like Elasticsearch enhance the result of a search and help improve website performance.
To get an idea of what Elasticsearch is and how it works, you should read our Co-Founder Aaqib Gadit’s blog post. This post should give you a fair idea of why Cloudways fell in love with this innovative search feature, to the point that it’s integrated within our hosting platform.
In this tutorial, you’ll learn how to configure Elasticsearch on WordPress. This is simpler than it sounds, especially if you are an active customer of Cloudways. So let’s find out how it is done!
What Is Elasticsearch?
Elasticsearch was released in 2010 and is used to search queries faster in large databases. Elasticsearch is extremely fast around raw data and is a highly scalable search engine, unlike conventional searches. Elasticsearch has an extensive API that can be integrated into any web application, including WordPress for big data discovery.
Elasticsearch in WordPress plays an integral part in the poor and slow performance of its default searching capabilities. It may look OK on a site with small databases, but it gets painful for the visitors trying to find their product from 50 different categories. Elasticsearch offers real-time index updates that instantaneously add a new document to the index.
Why Use Elasticsearch?
Large websites with directories and archives on various categories can utilize Elasticsearch. Online stores with thousands of products can reduce the search time using Elasticsearch in WordPress. This also improves the user experience as it allows customers to further narrow down their search queries to find the desired product faster.
Another amazing feature of Elasticsearch is the ability to monitor applications in real-time. This indexes the search data and makes logs for future analysis. It is a useful feature for e-commerce stores that wish to see trends in customers’ buying behavior and set their marketing strategies accordingly.
Cloudways Provides Elasticsearch FREE on 1-Click.
Explore all features Now
How to Configure Elasticsearch on WordPress on Cloudways (Easy Steps)
First of all, to configure Elasticsearch on WordPress, you must keep the following points in mind:
- You need to have an account at Cloudways and have backups in place.
- You should be comfortable with editing WordPress files.
- You should be familiar with WP-CLI.
Step 1: Enable Elasticsearch
- Access the Cloudways platform.
- Go to “Settings & Packages” in Server Management.
- Click “Packages”.
- Enable Elasticsearch by selecting the version.
This will enable Elasticsearch on your current server.
Note: Cloudways supports Elasticsearch up to version 7.6. And the ElasticPress plugin also supports the 7.6 version.
Step 2: Install ElasticPress on WordPress
According to Taylor Lovett, Project Lead ElasticPress and Director of Web Engineering at 10up:
“MySQL is inherently not created for complex search queries. Elasticsearch, on the other hand, is. To achieve highly relevant search results, filtration, or any other sort of advanced search functionality with WordPress, Elasticsearch is pretty much required. ElasticPress is the easiest and most effective way to integrate Elasticsearch with WordPress.”
According to Chris Wiegman, the Senior Web Engineer at 10up:
“ElasticPress integrates WordPress’ search with the Elasticsearch, offering an inexpensive way to make users’ search experience more useful. It offers powerful advanced search features with infinitely scalable features, by offloading the search to a service designed specifically to handle this need at large scale.”
Follow the steps below to install ElasticPress, a WordPress Elasticsearch plugin.
- Log in to your WordPress dashboard.
- Click Add Plugins.
- Search for the plugin named “ElasticPress“.
- Click “Install Now“.
Step 3: Edit the wp-config.php File
Next, we need to define the IP, and port Elasticsearch is running from. On Cloudways, Elasticsearch operates from the same server as our WordPress website.
- Edit your wp-config.php file and define EP_HOST as below.
/** ElasticPress */ define( 'EP_HOST', 'http://127.0.0.1:9200' );
Note: I added the local IP as ElasticPress runs on the same server as my WordPress and considers it a local environment. Else, you need to mention the server IP address where Elasticsearch is installed.
- If you cannot upload the updated wp-config.php file, you may need to reset permission by navigating to Application Management → Application Settings.
This will connect your WordPress site to Elasticsearch on your server through the ElasticPress plugin.
- Get back to WordPress Dashboard → ElasticPress and click on Sync.
Step 4: Build Indexes and Activate Elasticsearch
- Finally, log in to your SSH terminal through Cloudways Platform, build the ES indexes, and activate the feature.
Follow the steps below to log in to the SSH terminal:
- Head over to the “Server“.
- Click “Master Credentials“.
- Click “Launch SSH Terminal” or use Putty to connect to your server.
- From the top left bar, click on Applications and then get into your specific application.
- From the right side, create Application Credentials that will be used to access the application via SSH and SFTP.
- Now, head back to the SSH Terminal window and use the above credentials to get into the application.
Similarly, you can also access your application directly from the SSH Terminal present inside your server dashboard.
- Launch the terminal and login with your master credentials.
- Inside your terminal window, run the ‘cd applications’ command to access the applications running on this server.
- Type ‘ls’ to get the list of applications.
You could have just one or twenty applications running on your server. To access the one, you need to work on, type the following command.
cd [name of the application] cd [name of the folder]
That’s it! You are in the desired folder of your desired application.
WP-CLI is required to run ElasticPress specific commands. On Cloudways, each WordPress instance comes pre-installed with WP-CLI.
- First, run the following command to build ES indexes.
wp elasticpress index --setup
- You will see the output as follows:
ES usually activates itself after running the index. But to be on the safer side, run this command to make sure it is enabled.
wp plugin activate elasticpress
Deploying Elasticsearch on WordPress or WooCommerce websites will improve the search experience and improve the capability of your site to handle more search queries. Especially for a WooCommerce site as the number of searches increases on an e-commerce website.
For more insight on the supported commands of ElasticPress in WP-CLI, navigate here.
On Cloudways, you get WP-CLI and Elasticsearch pre-installed. If you are not on Cloudways, you will need first to install WP-CLI on your server and then Elasticsearch. Quite a hassle? Time-consuming? Then let us take care of all your installation hassles and save your time by signing up on the most optimized cloud hosting platform.
What is the best WordPress Elasticsearch plugin?
We have already seen ElasticPress in action, which is by far the simplest and most effective plugin. However, other plugins are available with additional functionalities, such as WPSOLR, a paid plugin.
Customer Review at
“Beautifully optimized hosting for WordPress and Magento”
Arda Burak [Agency Owner]