How to make MySQL treat underscore as a word separator for fulltext search? How to make MySQL treat underscore as a word separator for fulltext search? codeigniter codeigniter

How to make MySQL treat underscore as a word separator for fulltext search?


I know I could just replace all underscore occurrences in the DB by spaces, but this would compromise the original integrity of those titles though. Just wondering if there's another way of doing this.

You can instead of replacing underscores in original title field, use a separate field dedicated to fulltext searches.

This allows you to replace underscores, plus aggregates keywords into this field (category names, authors, tags, etc.) to enhance search results relevance. We used this a lot of times with success for getting rid of HTML tags in content infering with search


I don't think this can be done without access to the server. The only way I have ever seen to do it is the first comment on this mySQL manual page ("How I added '-' to the list of word characters"). It requires stopping the server and changing internal configuration.

Your best bet is probably creating a second column with removed underscores, and to search that.