简体   繁体   中英

mysql match against query

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM