WordPress is one of the most popular software programs on the planet, with more than 70 million websites on the internet. It’s one of the best content management software, and it’s evolving with every version.

It works on the concepts of MySQL; hence, it is slow with searches. Performing WordPress ElasticSearch Integration allows for improving the flaws WordPress has and making it more efficient.

ElasticSearch is distributed, fast, RESTful Search engine software meant for search and analytics. It is based on Apache Lucene and written in Java. It is one of the fastest search engines and can be combined with various applications.

This article gives a comprehensive guide on setting up WordPress ElasticSearch Integration.

What is ElasticSearch?

Wordpress elasticsearch: elasticsearch

Elasticsearch is a distributed, open-source search and analytics engine. It is built on Apache Lucene and developed in Java language. It started as a scalable version of the Lucene open-source search framework then added the ability to horizontally scale the Lucene indices.

Elasticsearch allows you to store, search, and analyze huge volumes of data quickly and in near real-time and give back answers in milliseconds. It’s able to achieve fast search responses because instead of searching the text directly, it searches an index.

It uses a structure based on documents instead of tables and schemas and comes with extensive REST APIs for storing and searching the data. At its core, you can think of Elasticsearch as a server that can process JSON requests and give you back JSON data. 

Elasticsearch’s primary use cases and provide examples of how companies are using it today.

Primary Use Cases

  • Application search: ElasticSearch allows for an easier search for applications that rely heavily on a search platform for the access, retrieval, and reporting of data.
  • Website search: Websites that store a lot of content find Elasticsearch a very useful tool for effective and accurate searches. It’s no surprise that Elasticsearch is steadily gaining ground in the site search domain sphere. 
  • Enterprise search: Elasticsearch allows enterprise-wide search that includes document search, E-commerce product search, blog search, people search, and any form of search you can think of. In fact, it has steadily penetrated and replaced the search solutions of most of the popular websites we use on a daily basis. From a more enterprise-specific perspective, Elasticsearch is used to great success in company intranets.
  • Logging and log analytics: As we’ve discussed, Elasticsearch is commonly used for ingesting and analyzing log data in near-real-time and in a scalable manner. It also provides important operational insights on log metrics to drive actions. 
  • Infrastructure metrics and container monitoring: Many companies use the ELK stack to analyze various metrics. This may involve gathering data across several performance parameters that vary by use case.
  • Security analytics: Another major analytics application of Elasticsearch is security analysis. Access logs and similar logs concerning system security can be analyzed with the ELK stack, providing a more complete picture of what’s going on across your systems in real time.
  • Business analytics: Many of the built-in features available within the ELK Stack make it a good option as a business analytics tool. However, there is a steep learning curve for implementing this product and in most organizations. This is especially true in cases where companies have multiple data sources besides Elasticsearch–since Kibana only works with Elasticsearch data.
  • A good alternative is Knowi, an analytics platform that natively integrates with Elasticsearch and allows even non-technical business users to create visualizations and perform analytics on Elasticsearch data without prior knowledge or expertise of the ELK Stack.

Related: Demystify the intricacies of ingest pipelines in Elasticsearch. Discover how Elasticsearch’s powerful tools can transform your data ingestion process, allowing you to preprocess and enrich your data seamlessly before indexing it into Elasticsearch in our comprehensive guide on how to ingest data to Elasticsearch.

Simplify Your WordPress and Elasticsearch Integration with Hevo

Hevo Data simplifies data integration by enabling you to connect diverse sources like Elasticsearch and WordPress via MySQL to any destination, including leading data warehouses. With its no-code platform, you can ensure real-time data transfer and maintain accuracy without the hassle of manual configurations.

Check out what makes Hevo amazing:

  • It has a highly interactive UI that is easy to use.
  • It streamlines your data integration task and allows you to scale horizontally.
  • Transparent pricing with various tiers to choose from to meet your varied needs. 
  • The Hevo team is available around the clock to provide exceptional support to you.

Hevo has been rated 4.7/5 on Capterra. Know more about our 2000+ customers and give us a try.

Get Started with Hevo for Free

What is WordPress?

Wordpress elasticsearch: wordpress logo

WordPress is a free, open-source website creation platform. On a more technical level, WordPress is a content management system (CMS) written in PHP that uses a MySQL database. In non-geek speak, WordPress is the easiest and most powerful blogging and website builder in existence today.

Features of WordPress

As a website-building platform and CMS, WordPress boasts an impressive feature set. Here are just a few of the many features of WordPress.

  • SEO: Search Engine Optimization (SEO) begins at a technical level and WordPress delivers an exceptional code base for SEO. SEO allows your website’s content to be found via common search engines such as Google or Bing. Check out these free WordPress SEO training videos to learn more.
  • Speed: WordPress is a lean website framework that is constantly striving to remove code “bloat” that slows down the loading speed of a website.
  • Mobile-friendly: Most WordPress themes are now mobile-friendly or responsive out-of-the-box.
  • Media file library: WordPress includes a built-in media library where you can upload and embed media files such as images or videos into your pages or posts. You can even perform basic edits to your images within WordPress.
  • Easy-to-use user interface: WordPress is very easy to use with no complicated settings. If you can use a WordPress processor, you can use WordPress. WordPress also has a focus on accessibility.
  • Custom menus: WordPress makes it easy to create navigation menus with links to your pages or custom links.
  • Built-in blog: Adding a blog to your website is as simple as publishing a post.

Related:

Why Integrate WordPress with Elasticsearch?

  • Enhanced Search Performance: Delivers faster, more accurate search results for a seamless user experience.
  • Advanced Search Capabilities: Supports complex queries and custom filters for more tailored search options.
  • Scalability: Maintains performance even with a large volume of content and growing website traffic.
  • Improved User Engagement: Helps users find relevant content quickly, boosting site interaction.
  • Better Site Navigation: Enhances user experience by making content discovery more intuitive and efficient.

WordPress ElasticSearch Integration

WordPress has an inbuilt search engine that can be used as a widget but it works on concepts of MySQL. MySQL is efficient for storing data but when it comes it retrieval and working with analytics it is not suitable.

It also slow when a large number of queries are run simultaneously. ElasticSearch works on the concepts of Rest API. It is a Search engine software meant for search and analytics. It is based on Apache Lucene and written in Java hence providing efficiency.

Performing WordPress ElasticSearch Integration allows overcoming all the disadvantages of using a general WordPress Search Engine.

WordPress ElasticSearch is a 4 step process

WordPress ElasticSearch: Install and Configure WP-CLI

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

or

wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

NOTE: Using wget, if you get an error about the SSL certificate mismatch between www.github.com and raw.githubusercontent.com domains, you can skip the certificate check to download the file with:

wget –no-check-certificate https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  • Then test WP-CLI directly with PHP with this command:
php wp-cli.phar –info
  • You should see output similar to:

PHP binary:

/opt/cpanel/ea-php70/root/usr/bin/php 
PHP version:  7.0.26 php.ini

used:

 /opt/cpanel/ea-php70/root/etc/php.ini

WP-CLI root dir:

phar://wp-cli.phar WP-CLI packages
WP-CLI global config:  WP-CLI project config:   WP-CLI version: 0.24.1
  • Next, you’ll need to make the WP-CLI file executable and move it to your path:
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
  • Now you can simply use wp at the command line to access WP-CLI:
wp –info

Setup Bash Tab-to-Complete for WP-CLI

A great time-saving feature of command-line interfaces is using tab completion to quickly type in commands. You can add the ability to use tab completion for WP-CLI by setting it up in your local ~/.bash_profile file.

  1. Download the WP-CLI tab-completion file to your server.
curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash 

or

wget https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash
  • Move the WP-CLI tab-completion file to your home directory:
  • Now edit your ~/.bash_profile file to include the WP-CLI tab-completion file:
vi ~/.bash_profile
  • Add this line to the bottom of your ~/.bash_profile file:
source ~/wp-completion.bash
  • Now save this file
  • Back at the command line, make sure to source your ~/.bash_profile file by running this command:
source ~/.bash_profile
  • Now just type wp at the prompt, and hit Tab twice to see all the tab completions you just setup:
exampl3@server [/home/exampl3/public_html]# wp
cache  comment  eval  help  menu  plugin  role  shell  super-admin  transient
cap  core  eval-file  import  network  post  scaffold  sidebar  term  user  cli
db  export  media  option  rewrite  search-replace  site  theme  widget

Now that you have installed WP-CLI you can begin using the command line to manage your WordPress website(s).

WordPress ElasticSearch: Install Elasticsearch

The easiest way to install Elasticsearch is from their repositories instead of the OS default repos. This is still an easier option compared to a manual installation and ensures you’ll be able to easily keep Elasticsearch updated.

Install Elasticsearch on CentOS

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch 
  • Create an elasticsearch.repo file in /etc/yum.repos.d/ using Nano, VIM, or Emacs:
  • Add the following to the file:
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md
  • Save changes.
  • Now install Elasticsearch:
sudo yum install --enablerepo=elasticsearch elasticsearch 

The configured repository is disabled by default to prevent upgrading Elasticsearch when upgrading the rest of the system. Therefore, installation and upgrade commands must explicitly enable the repo.Open port 9200 in your firewall: Firewalld, UFW, CSF, etc. Or if you need to use another port, edit the Elasticsearch YAML file.Check that Elasticsearch is running on an open port:

curl -X GET localhost:9200 

If you receive curl: (7) Failed connect to localhost:9200; Connection refused, check your Firewalld settings again.

Install Elasticsearch on Debian

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
  • Install apt-transport-https to access packages with an SSL (HTTPS) connection:
sudo apt-get install apt-transport-https
  • Add the Elastic repo to a new elastic-7.x.list file:
  • Install Elasticsearch:
sudo apt-get update && sudo apt-get install elasticsearch 

Setting Elasticsearch as a System Service

  • Use the following command to start Elasticsearch now:
systemctl start elasticsearch
  • Use the following command to enable Elasticsearch to automatically start upon system reboot:
systemctl enable elasticsearch
  • Use the following command to check for any issues related to starting or enabling Elasticsearch:
systemctl status elasticsearch
Integrate WordPress via MySQL to Redshift
Integrate ElasticSearch to BigQuery
Integrate AWS Elasticsearch to Snowflake

WordPress ElasticSearch: Configure Elasticsearch

  • To make changes to Elasticsearch, edit the Elasticsearch YAML file:
nano /etc/elasticsearch/elasticsearch.yml
  • By default, Elasticsearch uses port 9200 or the next available port between 9200-9300. If you need to specify a different Elasticsearch port, change the following line and remove the # at the beginning:
#http.port: 9200
  • Ensure Elasticsearch is running on an open port, changing localhost to your domain or other hostnames as needed:
curl -X GET localhost:9200
  • To find your server IP in the command line, use
hostname -i
  • If this Elasticsearch installation will join a node cluster, change the hostname to a server IP address or server hostname and remove the # at the beginning of the following line:
#network.host: 192.168.0.1
  • You can also create descriptive node name for easier navigation among cluster setups by modifying the following line:
#node.name: node-1

WordPress ElasticSearch: Create WordPress Elasticsearch Connection

WordPress users that work with WP_Query objects can use the Elasticsearch search engine with ElasticPress in WordPress.

First, you will need to edit your wp-config.php file to include the location of your Elasticsearch server. In this example, Elasticsearch is on the same server as our WordPress site, so we add the following:

define( ‘EP_HOST’, ‘https://127.0.0.1:9200’ );

Next, you will need to install the ElasticPress plugin. The ElasticPress plugin is available both within the WordPress plugin directory or within GitHub. If you want the most updated version, we recommend GitHub.

Of course, Elasticsearch isn’t doing us any good if we don’t have any data populated within it. To begin, log into your server via SSH and execute one of the following:

For single WordPress sites

wp elasticpress index –setup

For cross-site search on multisite

wp elasticpress index –setup –network-wide

ElasticPress is now running on your site and all searches are now WP_Query is now handling searches with WordPress Elasticsearch instead of running MySQL queries for your data. For more information on ElasticPress, check out the ElasticPress GitHub page.

Conclusion

This article provided a comprehensive guide on integrating ElasticSearch with WordPress, detailing the steps required for configuration. While this integration is highly efficient, setting up the proper environment can be complex and time-consuming.

Hevo Data simplifies this process. As a No-code Data Pipeline, Hevo offers 150+ pre-built integrations, making it easy to connect WordPress and other data sources. With Hevo, you can seamlessly load data into any destination for real-time analysis using BI tools like Tableau. Hevo is user-friendly, reliable, and secure, making data migration hassle-free and efficient. Sign up for Hevo’s 14-day free trial and experience seamless data migration.

FAQs

1. What is Elasticsearch in WordPress?

Elasticsearch is a powerful search engine that enhances the search functionality of WordPress sites by providing fast, relevant, and scalable search results.

2. Which plugin is best for Elasticsearch?

Some popular plugins for integrating Elasticsearch with WordPress include SearchWP, ElasticPress, and Relevanssi, with ElasticPress being a strong choice for robust integration.

3. What is Elasticsearch used for?

Elasticsearch is used for full-text search, real-time data analysis, and complex search queries, enabling fast and efficient data retrieval in applications and websites.

Arsalan Mohammed
Research Analyst, Hevo Data

Arsalan is a research analyst at Hevo and a data science enthusiast with over two years of experience in the field. He completed his B.tech in computer science with a specialization in Artificial Intelligence and finds joy in sharing the knowledge acquired with data practitioners. His interest in data analysis and architecture drives him to write nearly a hundred articles on various topics related to the data industry.