问题
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