处理MySQL全文特殊字符 [英] Handling MySQL Full Text Special Characters

查看:826
本文介绍了处理MySQL全文特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在布尔模式下使用MySQL全文搜索时,有些特定的字符如+和 - 用作运算符。如果我搜索类似C ++的东西,它会将+解释为运算符。处理这些特殊字符的最佳做法是什么?



我正在使用的当前方法是将数据中的所有+字符转换为_plus。它还将&,@,/和#字符转换为文本表示。使用MySQL的全文搜索。你在做什么(用一个预定义的字符串替换特殊字符)是做到这一点的唯一方法。



您可能希望考虑使用 Sphinx搜索。它显然支持转义特殊字符,并且所有报告都比默认的全文搜索快得多。


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.

解决方案

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.

这篇关于处理MySQL全文特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆