Mitch has written a nice tutorial about using ElasticSearch with Laravel 5.


I was recently asked to make a search engine for a client’s website. Normally I would go down the MySQL fulltext search route but I was feeling rather adventurous at the time. I had no experience with ElasticSearch, Apache Solr or any other search system prior to this so I decided to pick ElasticSearch and dive in head first. This tutorial is a result of some of the things I picked up while learning it.

I aim to show you how to set up the Elasticquent Laravel package and some basic ways to fine tune your search engine.

Note: This tutorial is aimed at developers who are already familiar with Laravel but are new to ElasticSearch and want some guidance on getting them to work together.

Installing ElasticSearch

If you haven’t installed ElasticSearch then make sure you check the ElasticSearch documentation for setting it up. Although not necessary it’s worth running through the rest of the getting started guide to understand the basics of how ElasticSearch works.

I also recommend Postman App if you use Chrome. Postman will let you run REST commands in a nice GUI rather than using command line.

Confirm that your ElasticSearch instance is running by the following command in your command line / Postman App.

curl -XPOST 'http://localhost:9200/?pretty'

You should see a nice prettified json response if everything is working okay.

    "status": 200,
    "name": "Mystique",
    "cluster_name": "elasticsearch_mitch",
    "version": {