Question

I have a table that is populated with certain values e.g.

| CODE  | NAME        | NB: THIS IS A VERY BASIC EXAMPLE
| zygnc | oscar alpha |
| ab-cd | delta tiger |
| fsdys | delta bravo |

Using MySQL Full-Text Boolean search i would like to search this table for all names containing 'delta' but exclude the first result basic on its unique code 'ab-cd'. This code contains a minus sign and this is a requirement and removing this would not be possible.

So the following query 'should' in my mind accommodate for this:

SELECT code, name
FROM items
WHERE MATCH (code, name)
AGAINST ('delta -"ab-cd"' IN BOOLEAN MODE)

However, running this query does not product the desired result in that the result does still contain the row with the code that is meant to be excluded, 'ab-cd'.

The Coalition of these two tables are set to utf8_bin.

The ft_min_word_len value is set to 4.

Could someone possibly suggest a reason for this behavior, I assume that it treats the string possibly as two separate values, e.g. "-ab", "-cd" and as the ft_min_word_len value is 4, neither of these two strings can produce any result?

I would think that the use of the encapsulation "", would mean that the second minus sign would be treated as literal but it seems that this is not the case. Perhaps it has something to do with the table coalition that i am not aware of?

In any case, any suggestions/advice/input/feedback/direction would be greatly appreciated, thank you!!

Was it helpful?

Solution

You need to change the value of variable ft_min_word_len in my.cnf file.

By default ft_min_word_len value is 3. Once change the variable, you need to restart the server.

Here "ab-cd" treated as two words as "ab" and "cd". So minimum word length is not matched with the words.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top