Giang Nguyen
Giang Nguyen

Reputation: 485

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;

Upvotes: 0

Views: 88

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269503

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.

Upvotes: 1

Related Questions