RoboRobok's avatar

Decent search engine for Laravel 5

I have a search engine on my Laravel website, but it's quite dumb. It just uses WHERE column LIKE '%needle%' pattern, so it's actually a little useless for multiple words searching. What are current trends for searching? Are external APIs the best choice? If so, which ones?

By the way, I'm using InnoDB tables, because I love foreign keys.

0 likes
12 replies
martinbean's avatar

@RoboRobok There are a plethora of options. Elastic Search, Sphinx, Lucene, Solr, Algolia, and many, many others.

willvincent's avatar

Any search implementation that does not use a dedicated search tool is going to either be slow, or limited... if that weren't the case, there'd be no need for things like elasticsearch, solr, sphinx, et al.

But if you're really opposed to setting up a dedicated search appliance, your best bet would be something like this, which leverages the php version of lucene (the same library that powers solr): https://packagist.org/packages/nqxcode/laravel-lucene-search

RoboRobok's avatar

@willvincent What would be differences between this package and, let's say, Elasticsearch? I'm new to search engines, so I'm asking :)

willvincent's avatar

@RoboRobok that package would be.. just that, a package. ElasticSearch, Solr, etc are whole other server process that you set up and run on your server, or a different server.

RoboRobok's avatar

Any advantages / disadvantages between them? So far I'm leaning towards Elasticsearch, just because of its popularity.

SamuelPB's avatar

@RoboRobok I used it for a small project quickly developed with very limited trafic. For my purpose it worked well enough. I even query the model through an API with vue.js. Works ok.

But then yeah go for elastic search that is quite nice to use.

RoboRobok's avatar

This package you recommended does exactly the same thing I'd do my own if I wanted to stick to pure DB solution. In other words, it's awesome. :)

wiedem's avatar

'Real' indexing services like Elasticsearch scale very well and are state of the art for full text searches. If you have to create a platform for anything more than a few users or private purposes this is definitely a recommended technology to use.

There are quite a few Elasticsearch packages out there for Eloquent.
I even released one my own not long ago https://github.com/Elodex/Elodex, the Quickstart tutorial should give you an idea how it works.
Another popular package would be Elasticquent which uses a little different approach than mine.

1 like
RoboRobok's avatar

I need to check Elasticsearch out. So far I have no idea how it works. I can only imagine that you send you contents to it somehow.

SamuelPB's avatar

@RoboRobok

Yes you send JSON payload that are highly configurable. You get the opportunity to use AND or OR key words within the text value, you can precise the index and so on. Very useful and easy to use. Kind of scary when you see the doc though ;)

Please or to participate in this conversation.