Handling MySQL Full Text Special Characters

前端 未结 2 1560
礼貌的吻别
礼貌的吻别 2021-01-18 07:58

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 interp

2条回答
  •  情话喂你
    2021-01-18 08:33

    MySQL is fairly brutal in what tokens it ignores when building its full text indexes. I'd say that where it encountered the term "C++" it would probably strip out the plus characters, leaving only C, and then ignore that because it's too short. You could probably configure MySQL to include single-letter words, but it's not optimised for that, and I doubt you could get it to treat the plus characters how you want.

    If you have a need for a good internal search engine where you can configure things like this, check out Lucene which has been ported to various languages including PHP (in the Zend framework).

    Or if you need this more for 'tagging' than text search then something else may be more appropriate.

提交回复
热议问题