带有单引号的全文查询 [英] Full text query with a single quote

查看:233
本文介绍了带有单引号的全文查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在布尔模式下使用带有单引号和星号通配符的字符串(即levi's *)进行全文搜索时,出现问题:它似乎也搜索以 s,就像矛一样,据我所知,引号应该被认为是单词的一部分,而两个单引号('')将是一个单词分隔符......但也许我错了。 p>

请看这里的例子: http://www.sqlfiddle.com/#!2/3dd3e/2/0 - 第二行不应该在那里



如何我可以做我想做的事吗?

解决方案

这给了你示例中的两行:

  SELECT * 
FROM ft
匹配(值)反对(''levi's'lacost *'BOOLEAN模式)

http://dev.m ysql.com/doc/refman/5.5/en/fulltext-boolean.html ,它会在双引号中讨论完全匹配。您只需转义单引号即可完成。



使用圆括号,您可以添加星号:

  WHERE MATCH(value)AGAINST('(levi \'s)* lacost *'BOOLEAN模式)


I'm having a problem when I try to do a full text search in boolean mode using a string with a single quote and an asterisk wildcard, i.e. "levi's*": it seems to search also for all words beginning with "s", like "spears", when, as far as I know, the quote should be considered part of the word while two single quotes ('') would be a word separator... but maybe I'm wrong.

Please, look at the example here: http://www.sqlfiddle.com/#!2/3dd3e/2/0 - the second row should't be there

how can I do what I want?

解决方案

this gives you the two rows from your example:

SELECT  *
FROM    ft
WHERE   MATCH(value) AGAINST ('"levi\'s" lacost*' IN BOOLEAN MODE)

In http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html at the end, it talks about exact matches in double quotes. You then just escape the single quote and you are done.

Using parentheses, you can add the asterisk:

WHERE   MATCH(value) AGAINST ('(levi\'s)* lacost*' IN BOOLEAN MODE)

这篇关于带有单引号的全文查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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