marcelosalloum
marcelosalloum

Reputation: 3531

Mysql MATCH AGAINST options: exact phrase along with extra word

I am trying to enhance a third part (awesome) django framework named django-watson and I currently need to make my way through a so far unknown mysql option, the MATCH (...) AGAINST (...).

So, I already know how to retrieve an exact phrase, which is doing:

SELECT * 
FROM patient_db 
WHERE MATCH ( Name, id_number ) 
AGAINST ('"exact phrase"' IN BOOLEAN MODE);

An I also know how to retrieve results that contain words from a list:

SELECT * 
FROM patient_db 
WHERE MATCH ( Name, id_number ) 
AGAINST ('+keyword1 +keyword2' IN BOOLEAN MODE);

But I need a third option, which is mixing the two above quoted. I'd like to do something like the google search: "exact phrase" +keyword1 +keyword2.

_PS: when I search for "exact phrase" -keyword1 it works exactly as desired _

Any Ideas?

Upvotes: 2

Views: 4238

Answers (1)

echo_Me
echo_Me

Reputation: 37253

Try this.

  SELECT * 
  FROM patient_db 
  WHERE MATCH ( Name, id_number ) 
        AGAINST ('+keyword1 +keyword2' IN BOOLEAN MODE)
  OR    MATCH ( Name, id_number ) 
        AGAINST ('"exact phrase"' IN BOOLEAN MODE)

Upvotes: 2

Related Questions