Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

Setup Laravel 5.7 Application in Just 1-click on Different Cloud Providers Like GCE , AWS , DO , Linode , Vultr Deploy Now!

How to Setup Elasticsearch with Laravel 5

Updated on May 12, 2016

3 Min Read
Reading Time: 3 minutes

Elasticsearch is a server based tool that is capable of full-text searching at very high speed. It is powered by Apache Lucene (which is an open source full text search library). It is able to achieve this speed because instead of searching the whole word matching the desired result from the whole database, it uses indexing.

This is similar to the indexing of a book. In this case, indexes are made out of letters. So as soon as you start searching, the Elasticsearch mechanism starts hovering to your result matching your first letter entries.

Elasticsearch with Laravel

How Do I Set It Up?

We will learn in this little tutorial about how we can setup Elasticsearch with our Laravel App. We will see some basic examples and will start working with them. I would love it if you follow the guide side by side so you can make changes accordingly for better learning.


  •   You have an activated server on Cloudways. Click here to launch one.
  •   You have an active Laravel App installed on your server.
  •   You have installed Elasticsearch on your Cloudways Server. If not click here to see the related guide.

Step 1:  Checking Elasticsearch Installation

Open up SSH terminal and enter the following command

System Settings
Step 2: Installing Elasticsearch Client for PHP Laravel

laravel cta

Step 3: Checking Elasticsearch

Let’s make some changes in our routes.php and see if we can check our client installation.

Now edit a route:

Now browse your app and you will get something like this:

Now let’s see how can we inject into our Elasticsearch:

Now get into your browser:

This will give you a result which is something like this:

Now let’s pull the data out using search queries. We will make a new route and will try finding our results by giving the input age:

Now go to your browser and type:

You will get something like this:

There you go, you have configured your Laravel app with Elasticsearch.

Cloudways provides the most optimized Managed Laravel Hosting experience in the cloud industry. Elasticsearch is also available on the platform. Combined with 24/7 Live Chat support, you can host your PHP web apps on the best infrastructure and avail Elasticsearch.

Share your opinion in the comment section. COMMENT NOW

Noor Ali

Noor Ali is an Associate Software Engineer at Cloudways. He loves to solve technical problems through programming and mathematics.

Launch Laravel apps with 1-Click Install. Painless Server Management

Deploy your apps on optimized Laravel hosting servers.

Get Our Newsletter
Be the first to get the latest updates and tutorials.