Link to home
Start Free TrialLog in
Avatar of dolythgoe
dolythgoe

asked on

FULLTEXT exact matching problem with a comma separating the words

Hi all,

So I have a simple FULLTEXT query that performs an exact match:

SELECT link_id FROM textdump
WHERE MATCH (link_tags)
AGAINST ('"one two"' IN BOOLEAN MODE)

Open in new window


Problem is, this sees "one,two" as an exact match when it isn't as there's a comma between them.

How can I get round this?

Cheers
David
Avatar of PranjalShah
PranjalShah
Flag of United States of America image

Try creating a full text index on your table with that column

ALTER TABLE table_name ADD FULLTEXT(columnName)

 
Avatar of dolythgoe
dolythgoe

ASKER

That has been done - I don't think you can run the query without one!
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Found this on MySQL site:

Nonword characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. For example, "test phrase" matches "test, phrase".

Hmm not helpful in my case! There must be way to match on the ',' as words are often delimited by them..
Ah thanks - soz, saw your post after mine! Will check it out and be back...
Yes, exactly. See if link above helps as it shows how to make some punctuation stop words. I am emailing who I believe the author is to see if he will post here, since I have not tried this out myself. If it works for you, then great. If not, then hopefully someone like that can confirm; however, per the documentation it is working as designed by MySQL as you have found.
Uhhh, that's a bit of a ball ache :( ! I might just match anyway and then get php to check if there's a comma in it or not - it's only for a worker-type cron script so I might skip the character encoding bit.

Will award points - it's the right solution! Thanks.
Cool. Keep in mind too, you might be able to do this outside of FULLTEXT.

SELECT link_id
FROM textdump
WHERE link_tags LIKE '%one two%'

Kevin