Near matches not found in CONTAINSTABLE

这一生的挚爱 提交于 2019-12-12 16:13:46

问题


I am using SQL Server 2008

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?


回答1:


'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'.



来源:https://stackoverflow.com/questions/11994281/near-matches-not-found-in-containstable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!