New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natural Language Full-Text Searches MATCH (title,body) AGAINST ('word') #214

arnigudj opened this Issue Jan 30, 2013 · 5 comments


None yet
5 participants
Copy link

arnigudj commented Jan 30, 2013

It's very easy to search with MYSQL LIKE searches.

Article::where('title', 'like', '%first%');

But, what would be the best way to use MYSQL Natural Language Full-Text Search?

SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('first');

Anybody that has tried to do this in Laravel 4 with Eloquent model?

Would be nice to have something like

$articles = Article::match('title|body')->against('word1|word2');


$articles = Article::matchAgainst('title|body','word1|word2');

This comment has been minimized.

Copy link

taylorotwell commented Jan 30, 2013

Full text search is pretty vendor specific and not something that is currently supported by Laravel. You would need to run a raw query. Also, let's try to keep the Github Issue posting for actual "issues" or bugs. If you have a question a better place to ask would be the forums.


This comment has been minimized.

Copy link

arnigudj commented Jan 30, 2013

ok will do


This comment has been minimized.

Copy link

ghprod commented Jul 12, 2013

try this

Article::whereRaw('MATCH (title, content) AGAINST (?)' , array($search))


This comment has been minimized.

Copy link

ganicus commented Nov 22, 2013

Any reason why

whereRaw('MATCH (title, content) AGAINST (?)' , array($search))


$search = 'searchterm*'

doesn't yield a wildcard response? As if the "*" wasn't being passed into the query?


This comment has been minimized.

Copy link

pc-paul commented Jan 5, 2017

While in theory

whereRaw('MATCH (title, content) AGAINST (?)' , array($search))

will work, I found that binding failed when used in AGAINST.

I used it without binding like so

whereRaw("MATCH (title, content) AGAINST ('$search1')")

however this leaves you open to SQL injection, so you would need to sanitize your variable $search1 first.

ConnorVG added a commit to ConnorVG/framework that referenced this issue Sep 26, 2017

[5.5] Add Missing Abstract Relation Method
For some reason, this method is not defined (not even as abstract) even though it's called within its self... (Take a look at aline laravel#214)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment