Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fulltext search on mysql with a 3 letter word

I'm trying to find "the zen" string in a field containing "The Zen Circus". I've got a FULLTEXT index.

select url,name,
,   MATCH(name) AGAINST ( 'zen*' IN BOOLEAN MODE) as A
,   MATCH(name) AGAINST ( '"the zen*"' IN BOOLEAN MODE) as B
,   MATCH(name) AGAINST ('>the* zen' IN BOOLEAN MODE) as C
,   MATCH(name) AGAINST ('thezen*' IN BOOLEAN MODE) as D
,   MATCH(name) AGAINST ('cir*' IN BOOLEAN MODE) as E
,   MATCH(name) AGAINST ('circus*' IN BOOLEAN MODE) as F
from pages where url='thezencircus'

I've got this result:

url = thezencircus
name = The Zen Circus
A = 0   (why?)
B = 0   (why?)
C = 0   (why?)
D = 0   (ok)
E = 1   (ok)
F = 1   (ok)

I've also putted ft_min_word_len = 2 in the msyql config file.

Any idea?

like image 869
Pons Avatar asked Oct 24 '12 12:10

Pons


2 Answers

See this answer MySQL full text search for words with three or less letters

[mysqld]
ft_min_word_len=3
Then you must restart the server and rebuild your FULLTEXT indexes.

Remeber to restart and rebuild indexes.


Edit
Run show variables like 'ft_%'; to confirm that the word length matches what you set it to.
like image 129
Kao Avatar answered Oct 18 '22 17:10

Kao


Kao is right but that didn't help me at all - why? InnoDB table uses a different setting - try updating this one and checking it with:

    show variables like 'innodb_ft_min_token_size';
like image 28
Scott Avatar answered Oct 18 '22 18:10

Scott