简体   繁体   中英

MySQL Boolean Full-Text Searches

I am currently using Boolean Full-text search for my website. However, this method will ignore words have less than 2 characters.

Example:

title: iphone 4 last sale

$raw_results = mysqli_query($conn,"SELECT * FROM memberpost WHERE MATCH(title) AGAINST('4' IN BOOLEAN MODE )") or die("no result found");

If i typed: '4' in search box, it will not return any result.

How can i make this works even with 1 character?

Thanks

SOLVED by adding to [mysqld] in my.ini file, restart mysql service.

innodb_ft_min_token_size = 1
innodb_ft_enable_stopword = OFF
ft_min_word_len = 1
ft_stopword_file = ''

Then run this query to repair table:

ALTER TABLE table_name FORCE;

The variable that controls this is ft_min_word_len , documented here . You would set it to 1 and probably also override the stop words list.

Note three things. After you reset it, you need to rebuild the index. Second, if you already handle two-character words, then this value has already been changed from the default. And three, there is also a stop words list which also filters terms out of the index.

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