lec*_*g92 3 sql-server full-text-search
fulltext
如果关键字有特殊字符,如何使用搜索进行搜索
"of", "-"
...等等
select * from table1
join CONTAINSTABLE (table1,(Title,Description_HTML),
'"of" and "Department"')
tb2 on tb2.[key] = table1.ID
Run Code Online (Sandbox Code Playgroud)
我无法查看结果?
正如马丁史密斯评论的那样,“这要看情况。” 控制全文索引处理的因素取决于您在CREATE FULLTEXT INDEX
命令中使用的配置。
有一个工具可以帮助您测试查询:https : //msdn.microsoft.com/en-us/library/cc280463.aspx
您可以使用sys.dm_fts_parser command
来测试全文结果。例如,使用此函数进行三个相似的搜索。
select * from sys.dm_fts_parser('"of" and "-" and "Department"',
1033, NULL, 0) --American English, No stop words, Accent Insensitive;
Run Code Online (Sandbox Code Playgroud)
返回 2 个令牌:of, Department
select * from sys.dm_fts_parser('"of""-""Department"',
1033, NULL, 0) --American English, No stop words, Accent Insensitive;
Run Code Online (Sandbox Code Playgroud)
返回 2 个令牌:of, Department
select * from sys.dm_fts_parser('"of-Department"',
1033, NULL, 0) --American English, No stop words, Accent Insensitive
Run Code Online (Sandbox Code Playgroud)
返回 3 个令牌:of-Department、of、Department
通常,单独站立时会忽略“-”。但是,根据全文索引中的语言选择,“-”在文本中用作连字符,可能会如第三个示例中所示进行报告,其中包括“of-Department”作为返回的标记之一。