Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling MySQL Full Text Special Characters

When using MySQL full text search in boolean mode there are certain characters like + and - that are used as operators. If I do a search for something like "C++" it interprets the + as an operator. What is the best practice for dealing with these special characters?

The current method I am using is to convert all + characters in the data to _plus. It also converts &,@,/ and # characters to a textual representation.

like image 939
ejunker Avatar asked Nov 14 '08 16:11

ejunker


People also ask

Which special characters are not allowed in MySQL?

ASCII NUL (U+0000) and supplementary characters (U+10000 and higher) are not permitted in quoted or unquoted identifiers. Identifiers may begin with a digit but unless quoted may not consist solely of digits. Database, table, and column names cannot end with space characters.

Does varchar allow special characters MySQL?

As the name suggests, varchar means character data that is varying. Also known as Variable Character, it is an indeterminate length string data type. It can hold numbers, letters and special characters.


1 Answers

There's no way to do this in nicely using MySQL's full text search. What you're doing (substituting special characters with a pre-defined string) is the only way to do it.

You may wish to consider using Sphinx Search instead. It apparently supports escaping special characters, and by all reports is significantly faster than the default full text search.

like image 95
Gary Pendergast Avatar answered Sep 22 '22 12:09

Gary Pendergast