Reputation: 780
I am using mysql match against query in my search query like this way
MATCH(film_name) AGAINST ('the vacation' IN BOOLEAN MODE).
But previously i use this one
film_name like '%the vacation%'
So my question is that i am getting the right result now by using match and against but the problem is that when i am using like there i can use the %
sign before and after the search string so if the search string present with in the string then it was return the result so plz tell how to write my " MATCH(film_name) AGAINST ('the vacation' IN BOOLEAN MODE) "
so that it also behaves `like '%'.
If the file name is 'rocketsingh'
then if i run film_name like '%rocket%'
then it shows me the result
but if i run MATCH(film_name) AGAINST ('rocket' IN BOOLEAN MODE)
then it will not show any result. Please suggest what to do.
Upvotes: 3
Views: 1521
Reputation: 5405
MATCH command allows only prefixed wildcards but not postfixed wilcards. Since single words are indexed, a postfix wildcard is impossible to manage in the usual way index does. You can't retrieve *vacation instantly from index because left characters are the most important part of index.
Upvotes: 2
Reputation: 44346
The answer is: You can't. The MATCH AGAINST
operator matches words, not strings. There is a difference between the two. Also note that your example will also match vacation
, the
, vacation the
or the something something vacation
and other. You should read here what searches you can do.
You should stick to your first option with LIKE
if you don't want word searches.
Upvotes: 0