How to use Full Text Search in WordPress with Elastic

Search in WordPress is very basic which query for like in a
database and give you the results. It doesn’t have indexing and
can degrade the performance if lots of search activity on your

It’s probably ok if you don’t have search functionality on your
blog. However, if you expect visitors to perform a search then
you must consider looking for alternative seriously.

If you are not sure whether people search on your website then
Analytics will help you to find out.

  • Login to Google Analytics
  • Go to Behavior >> All Pages
  • Search for ?s and see the number of
    queries was searched


In last 30 days, I received 314 queries with 453 page views.
It’s not very high but still worth considering some

Another problem with WordPress inbuilt search is when you query
for something and if it doesn’t match exactly then it will not
give any results.

For ex: I searched for “Seo Analyser” and say
no match.


To improve the searchability in WordPress, you can consider the
Elastic Search . Elastic Search is
one of the most popular open sources search softwares with
following features.

  • Real-time data & analytics
  • High availability
  • Multitenancy
  • Full-text search
  • Distributed
  • Document oriented
  • Schema-free
  • Built on Apache Lucene and developed in Java

Note: your website must be hosted on VPS
instead of shared hosting as you need to install ElasticSearch
software on it.

The following demonstration is done on Linode’s VPS – Ubuntu .

Installing Elastic Search

  • Login into your VPS with root
  • Sign the package with below command
wget -qO - | sudo apt-key add -
  • Add the repository to the list
echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
apt-get update && apt-get install elasticsearch
  • Add elastic search at boot so when server reboot it start
update-rc.d elasticsearch defaults

Installing Java

ElasticSearch is developed in Java so you need to have java
installed before you start it. To install execute the following

apt-get install default-jdk

Once installed, verify by executing java

 [email protected] :/etc/init.d# java -version
java version "1.7.0_101"
OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
 [email protected] :/etc/init.d#

Starting Elastic Search

You are all set to start ElasticSearch. Go to /etc/init.d and
execute following to start them.

./elasticsearch start

Note: Elastic Search by default starts on 9200
port. So if you want to access console, you can use

Integrating ElasticSearch with WordPress

Now, the final step is to integrate elastic search with the
WordPress. Thanks to “ Fantastic ElasticSearch ”
plugin which makes things super easy.

  • Login to WordPress and install Fantastic ElasticSearch
  • Once installed, click on ElasticSearch at left navigation
    for following basic configuration.

Under WordPress integration tab

  • Tick the checkbox for “Enable Search”
  • Tick the checkbox for “Enable for All category archives”


Under Server Settings tab


Under Result Scoring

  • Enter fuzziness amounts to 1



Fuzziness is important and setting this value to 1 means if the
user gives any one character wrong it will still match the
relevant words.

Be careful with fuzziness amount, having this
higher will have performance impact so you may want to limit
with 1 or maximum 2.

Under Manage Index tab 

  • Click on Reindex Data and don’t forget to Save Changes


Now, let’s take above example, I searched for “SEO Analyser”
and it didn’t give any result because I had articles contain
“SEO Analyzer”.

Let’s see what the results look like:


Awesome! As you can see it has searched for
the article, which has “SEO Analyzer” keyword.

Above are basic configurations and if you think need more
configurations then go through plugin settings. ElasticSearch
is a great replacement of inbuilt WordPress search and I hope
this article helps you in implementing them.


Leave a Reply

%d bloggers like this: