This article may help you setup your own ElasticSearch on your WordPress website, to make the search results super-fast :) Recommended on WooCommmerce websites with lots of products.
- ElasticSearch up & running.
- Wordpress Website.
- ElasticPress plugin.
Note: Above mentioned all three prerequisites are open-source (free to use) at the time of writing of this post.
Let’s Begin !
Setup your own Self-Hosted ElasticSearch Server :
################## On CentOS ############# ####
- First, install java8 on your CentOS server, using the below commands:
yum -y update
yum install java-1.8.0-openjdk
- Verify, Java is installed !
Let’s install ElasticSearch !
- Create a file inside the folder /etc/yum.repos.d/ named “elasticsearch.repo” using your favorite editor :
- Now, paste the below content inside this file, to make the repository ready to use :
name=Elasticsearch repository for 7.x packages
- Save and exit the file.
- Now, run the below command to install elasticsearch.
sudo yum clean all
sudo yum makecache
sudo yum update -y
sudo yum install elasticsearch-oss-7.9.1
- Now, to make sure elasticsearch is listening to outside traffic edit the file /etc/elasticsearch/elasticsearch.yml and uncomment & make the following changes :
- Start, the elasticsearch service after installation
sudo systemctl start elasticsearch
- Check status of the service :
sudo systemctl status elasticsearch
- Enable the elasticsearch service to start automatically on boot :
sudo systemctl enable elasticsearch
You are all set with your Self-Hosted ElasticSearch Server !
Now, Let’s move to the WordPress configuration
- First, login to your WordPress admin panel and install a plugin called “ElasticPress” :
- Once plugin is installed & activated, navigate to installed plugins, and click on Dashboard as shown below :
- You will be presented with the screen as shown below, click on “Got hosting?” since we already have our elasticsearch server setup:
- Next, select Third-Party/Self-Hosted option :
- Enter the URL of your elasticsearch server with port and save changes :
- Next up, click on index your data to send your search data from wordpress to elasticsearch :
- Select the Features tab in the plugin and save the below configuration :
- Also, enable auto-suggest feature and save it like below :
Note: More configuration can be done depending upon your use-case.
Voila ! You have successfully integrated ElasticSearch with your WordPress website.
Hope this article helps you implementing ElasticSearch on your WordPress website.
Hit clap button if you find this article useful. Thank You :)