Skip to content
Advertisement

match against doesn’t work with the word “when”

When desc contains the string: zoom when wifi dies for 1 second

Query 1:

SELECT * FROM `pics` WHERE MATCH(title, desc, owntags, usertags) AGAINST('+zoom* +wifi*' IN BOOLEAN MODE)

No problem, I get the row!

Query 2:

SELECT * FROM `pics` WHERE MATCH(title, desc, owntags, usertags) AGAINST('+zoom* +when*' IN BOOLEAN MODE)

No results! So when belongs to sql commands.

So how to solve this?

Advertisement

Answer

You need to learn some basics about full text search. One very important concept are stop words. These are words that are not included in the full-text index, because they are so common or add little meaning (at least from the perspective of the person who created the stop word list . . . a famous problem involves the band The Who).

The word 'when' is a common stop word and a default stop word in MySQL (see here and here). So, it is not being indexed.

You will need to recreate your full text indexes, either removing all stop words or using your own custom list.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement