Sql server MS SQL FTI-在“上搜索”;n*”;返回数字
从SQL的全文索引来看,这似乎是一种奇怪的行为 FTI在其索引中以“NN”前缀存储编号,所以“123”保存为“NN123” 现在,当用户搜索以N开头的单词(即包含“N*”)时,他们也会得到所有数字 因此: 返回: MyTable.TextField -------------------------------------------------- This text contains the word navigator This text is nice This text only has 123, and shouldn't be returned 将搜索文本n*-但没有Sql server MS SQL FTI-在“上搜索”;n*”;返回数字,sql-server,full-text-search,Sql Server,Full Text Search,从SQL的全文索引来看,这似乎是一种奇怪的行为 FTI在其索引中以“NN”前缀存储编号,所以“123”保存为“NN123” 现在,当用户搜索以N开头的单词(即包含“N*”)时,他们也会得到所有数字 因此: 返回: MyTable.TextField -------------------------------------------------- This text contains the word navigator This text is nice This text only has
--return rows with the word text
select [TextField] from [MyTable] where contains([TextField], 'text')
--return rows with the word tex*
select [TextField] from [MyTable] where contains([TextField], 'tex*')
--return rows with words that begin tex...
select [TextField] from [MyTable] where contains([TextField], '"tex*"')
有两种方法可以解决这个问题,但都不是很好 首先,在表中添加一列,说明
TextField
实际上是一个数字。如果你能做到这一点并进行过滤,你将拥有性能最好的版本
如果这不是一个选项,那么您需要添加一个进一步的过滤器。虽然我还没有对它进行全面测试,但您可以添加过滤器和文本字段,而不是像'NN%[0-9]'
不利的一面是,这会过滤掉“NN12NOO”,但这可能是您的数据无法表示的边缘情况。有几种方法可以处理这一问题,尽管两者都不是很好 首先,在表中添加一列,说明
TextField
实际上是一个数字。如果你能做到这一点并进行过滤,你将拥有性能最好的版本
如果这不是一个选项,那么您需要添加一个进一步的过滤器。虽然我还没有对它进行全面测试,但您可以添加过滤器和文本字段,而不是像'NN%[0-9]'
缺点是,这会过滤掉“NN12NOO”,但这可能是一个边缘情况,而不是由您的数据表示
select [TextField] from [MyTable] where contains([TextField], 'n*')
--return rows with the word text
select [TextField] from [MyTable] where contains([TextField], 'text')
--return rows with the word tex*
select [TextField] from [MyTable] where contains([TextField], 'tex*')
--return rows with words that begin tex...
select [TextField] from [MyTable] where contains([TextField], '"tex*"')