在CONTAINSTABLE中找不到匹配

在CONTAINSTABLE中找不到匹配

本文介绍了在CONTAINSTABLE中找不到匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用



DDL



  CREATE TABLE [dbo]。[t](
[words] [varchar](1000)NULL,
[id] [int] IDENTITY 1,1)NOT NULL
)ON [PRIMARY]



DML



插入t(字)值('这是我的笔记本电脑')
插入t(字)值('这不包含耳机')



SQL查询



<$ p $ t




$ b $ JOIN CONTAINSTABLE(t,words,'headphone *',10)fulltextSearch
ON
t.Id = fulltextSearch。[KEY]



结果



没有找到记录



我预计有一条记录。任何想法?

解决方案

'this'很可能是一个噪音词(如'the','and'等),所以它不会被包含在索引中。尝试搜索文本中的真实单词之一。



- 编辑 -



好的,那是不是... ...



我试过你的代码,它按照我的预期工作 - 查询返回了一条记录。唯一的区别是我将[id]定义为主键(您也必须这样做,否则您无法创建索引)。我打赌你的索引没有填充 - 在SSMS中,右键单击表格,选择'全文索引' - >'开始全部填充'。


I am using

DDL

CREATE TABLE [dbo].[t](
    [words] [varchar](1000) NULL,
    [id] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]

DML

insert into t(words)values('this is my laptop')
insert into t(words)values('this does not contains headphone')

SQL Query

SELECT *
FROM
t as t
JOIN CONTAINSTABLE(t, words,'"headphone*"', 10) fulltextSearch
ON
t.Id = fulltextSearch.[KEY]

Results

No record found

I am expecting one records. Any Idea?

解决方案

'this' is very likely a noise word (like 'the', 'and', etc), so it would not be included in the index. Try searching for one of the real words in your text.

-- EDIT --

Ok, that wasn't it...

I tried your code and it worked as expected for me - the query returned one record. The only difference is that I defined [id] as the primary key (which you must have done as well, or you couldn't create the index). I am betting your index is not populated - in SSMS, right click on the table, select 'full text index' -> 'start full population'.

这篇关于在CONTAINSTABLE中找不到匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 19:59