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

Closed
arnigudj opened this Issue Jan 30, 2013 · 5 comments

Comments

Projects
None yet
5 participants
@arnigudj
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');

or

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

This comment has been minimized.

Copy link
Member

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.

@arnigudj

This comment has been minimized.

Copy link
Author

arnigudj commented Jan 30, 2013

ok will do

@ghprod

This comment has been minimized.

Copy link

ghprod commented Jul 12, 2013

try this

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

@ganicus

This comment has been minimized.

Copy link

ganicus commented Nov 22, 2013

Any reason why

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

where

$search = 'searchterm*'

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

@pc-paul

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