撇号和SQL Server FT搜索 [英] Apostrophes and SQL Server FT search

查看:127
本文介绍了撇号和SQL Server FT搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SQL Server 2005中设置了FT搜索,但我似乎找不到一种方法将Lias关键字与Lia's的记录匹配。我基本上想要的是允许人们在没有撇号的情况下进行搜索。



我已经关闭了这个问题很长一段时间了,所以任何帮助都会真的成为祝福。编辑2:刚刚意识到这实际上并不能解决你的问题,请忽略并看看其他答案!

下面的代码将返回用户插入不应该在那里的撇号的情况的结果,例如放弃它的货物。

我没有已经在本地安装了FT并且没有测试过 - 你可以使用CONTAINS的语法来测试原始发生的情况,还可以使用撇号去除它,例如:

  SELECT * 
FROM table
WHERE CONTAINS('value'OR Replace('value','''',''))
 

SELECT *
FROM table
WHERE CONTAINS(this phraseOR Replace(this phrase,'''',''))

请参阅 CONTAINS的MSDN文档。这实际上表明标点符号被忽略了,但是我还没有测试;它可能值得仅仅尝试 CONTAINS('value')

I have setup FT search in SQL Server 2005 but I cant seem to find a way to match "Lias" keyword to a record with "Lia's". What I basically want is to allow people to search without the apostrophe.

I have been on and off this problem for quite some time now so any help will really be a blessing.

解决方案

EDIT 2: just realised this doesn't actually resolve your problem, please ignore and see other answer! The code below will return results for a case when a user has inserted an apostrophe which shouldn't be there, such as "abandoned it's cargo".

I don't have FT installed locally and have not tested this - you can use the syntax of CONTAINS to test for both the original occurrence and one with the apostrophe stripped, i.e.:

SELECT *
FROM table
WHERE CONTAINS ('value' OR Replace('value', '''',''))

EDIT: You can search for phrases using double quotes, e.g.

SELECT *
FROM table
WHERE CONTAINS ("this phrase" OR Replace("this phrase", '''',''))

See MSDN documentation for CONTAINS. This actually indicates the punctuation is ignored anyway, but again I haven't tested; it may be worth just trying CONTAINS('value') on its own.

这篇关于撇号和SQL Server FT搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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