Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Natural Language Full-Text Searches MATCH (title,body) AGAINST ('word') #214
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');
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.
While in theory
will work, I found that binding failed when used in AGAINST.
I used it without binding like so
however this leaves you open to SQL injection, so you would need to sanitize your variable $search1 first.