Watch out, Laravel Scout does not support Elasticsearch by default anymore!

Here, you know it now. You won’t get the frustration of learning it after following recent tutorials!

Jean-Philippe Murray
jpmurray.net

--

So yeah. My usual workflow, when there is a tool I never used before that I want to integrate to one of my project, never starts with reading the docs. I always prefer googling what I want to learn / use and check if there is any tutorial on the matter around. It normally pays off! More than often, there is someone who went through the same ordeal as you, and said person laid out the steps in layman’s term for you to digest for a first time. Then after, when you’re used to the process, I go check the documentation to get close and personal with the use of the tool.

The rule is simple: “keyword + tutorial”, show results that are no more than a year old and just look for the closest in time. It worked. Always! So when I wanted to integrate Laravel Scout with Elasticsearch, I didn’t think twice and did the search and what I found at least two tutorial in the past 3 months, I was satisfied enough.

The tutorials I followed made me composer install laravel/scoutand composer install elasticsearch/elasticsearch. Fair enough. After installing Scout, composer also suggested to install the elasticsearch package, cool! I added the trait to my mode and php artisan-ed the import command for Scout.

It works!

I have a farily big database to import, so I waited a little for at least some data to pour in and, over the excitement of using Elasticsearch so easily (!), I decided to use Tinker to test the search. Then, my world felt apart.

InvalidArgumentException with message ‘Driver [elasticsearch] not supported.’

Says who? I’m, at the moment, importing millions of rows into it, with the help of said driver!

As it turns out, after finding this issue over Scout’s Github repository, it would seem like Taylor Otwell removed the code Elasticsearch in the past months, and that references to Elasticsearch where removed from the composer file in the past days. It’s probably not tagged yet, hence the suggestion I’ve seen when I did install Scout. Maybe.

What I can’t understand is why I could start an import and not use the search method… But I’m glad I got excited and tried before all of my import was finished.

Alternatives? A quick search gives me two packages to give Scout support of Elasticsearch. One is ErickTamayo/laravel-scout-elastic and the other actually being a fork of the first who is behind the latests commit.

The issue referenced up there also has a comment from user “DMeganoski” who gives the code for his own driver he made himself. That code won’t update itself after some time if you use it, so I’d be tempted to a package, but then again, the package mentioned hasn’t seen an update in the past 4 months.

Has anyone found other packages to give Scout Elasticsearch support? Have you experience with the one from ErickTamayo?

I’ll have to test it myself soon enough, but later… I have to built back the excitement that I lost.

--

--

Studied religions and its people for some time, now I’m back working with the web. Passionate about technologies, the human being and the human becoming. FR/EN