I am looking to perform an exact match on a phrase within specified delimiters in MySQL. I have the following data in a full text index field.
,garden furniture,patio heaters,best offers,best deals,
I am performing the following query which is returning the aforementioned record.
SELECT id, tags
FROM Store
WHERE MATCH(tags) AGAINST(',garden,' IN BOOLEAN MODE)
I only want to return records which contain the value: ,garden, not ,garden furniture, or ,country garden, etc.
It is currently performing a greedy match and ignoring the comma delimiters specified in the query. I have attempted to escape the commas to force them to be included in the query, but this does not work.
Is is possible to specify non-alphanumeric delimiters as part of the match? I want to be able to perform an exact match, like a regular expression i.e '/,garden,/'.
From the docs:
Modify a character set file: This requires no recompilation. The
true_word_char()macro uses a “character type” table to distinguish letters and numbers from other characters. . You can edit the contents of the<ctype><map>array in one of the character set XML files to specify that ‘,’ is a “letter.” Then use the given character set for your FULLTEXT indexes. For information about the<ctype><map>array format, see Section 9.3.1, “Character Definition Arrays”.An other option is to add a new collation.
Either way, you’ll have to rebuild the index: