MySQL – Change Min Word Length for Specific Fulltext Search Query

full-text-searchMySQL

I can set it a new value by adding this line under the [mysqld] section in my.cnf configuration file:

ft_min_word_len = 3 // or any other length

But I don't want that. I want to know, can I do that in a specific query? I have this query:

select * from mytable where match(mycol) against(:val)

And I want to change ft_min_word_len just for query above. I don't want to change it in MySQL configuration file. I mean I want to have another min word length for other queries.

Best Answer

Short answer: Not possible.

Long answer...

That setting is used when any MyISAM FULLTEXT index is being built. You should change to InnoDB, in which case innodb_ft_min_token_size is the variable to set. (It defaults to 3.)

If you change the setting after the index is built, it has no effect on existing indexes or queries using those indexes.

The only way to change it is to (1) change it in my.cnf, then (2) rebuild the index on any table for which you want the new length.