views:

111

answers:

2

I use the following call for getting information from a database:

select * from submissions 
where 
   match( description ) against ('+snowboard' in boolean mode ) 
   and (!disabled or disabled='n') 
order by datelisted desc limit 30

Which means everything with ‘snowboard' in the description is found. Now here’s the problem:

select * from submissions 
where 
  match( description ) against ('+snowboard +mp4' in boolean mode ) 
  and (!disabled or disabled='n') 
order by datelisted desc limit 30

will ignore the +mp4 for some reason and return the same as the first querie

select * from submissions 
where 
   match( description ) against ('+mp4' in boolean mode ) 

doesn't return anything, so basically it appears it's ignored in the search

Does anybody know how to work around this behavior?

+2  A: 

mysql's boolean mode will only match words which are longer than a certain length. and mp4 is too short. you'd have to recompile mysql to change the threshold

EDIT: turns out, this can now be set via the config file, see http://dev.mysql.com/doc/refman/5.0/en/fulltext-fine-tuning.html for furhter reference

knittl
thanks for resolving this so quickly!
Patrick
+1  A: 

Your problem is the minimum word length, which by default is 3 characters. Try the same with +snowboard +scooter and you will see that it works. (Supposing you don't have scooters in your database, of course).

See Fine-Tuning MySQL Full-Text Search on how to change it:

The minimum and maximum lengths of words to be indexed are defined by the ft_min_word_len and ft_max_word_len system variables. (See Section 5.1.4, “Server System Variables”.) The default minimum value is four characters; the default maximum is version dependent. If you change either value, you must rebuild your FULLTEXT indexes. For example, if you want three-character words to be searchable, you can set the ft_min_word_len variable by putting the following lines in an option file:

[mysqld] ft_min_word_len=3

Then restart the server and rebuild your FULLTEXT indexes. Note particularly the remarks regarding myisamchk in the instructions following this list.

Pekka