简体   繁体   English

SQL Server全文索引

[英]SQL Server full-text index

I have a table with full text index created on it. 我有一个带有全文索引的表。

CREATE TABLE dbo._mytable
(
    ID INT CONSTRAINT Pk_mytable PRIMARY KEY CLUSTERED,
    Name NVARCHAR(50)
)
GO

CREATE FULLTEXT CATALOG ft AS DEFAULT
GO  

CREATE FULLTEXT INDEX ON dbo._mytable(Name)   
   KEY INDEX Pk_mytable   
GO

The following query runs successfully 以下查询成功运行

SELECT t.Name AS t_name
FROM dbo._mytable t
WHERE CONTAINS(t.Name, '"mu*"')

But this one fails 但是这个失败了

SELECT *
FROM 
    (SELECT t.Name AS t_name
     FROM dbo._mytable t) T
WHERE CONTAINS(T.t_name, '"mu*"')

Error: 错误:

Msg 7601, Level 16, State 3, Line 7 Msg 7601,第16级,状态3,第7行
Cannot use a CONTAINS or FREETEXT predicate on column 't_name' because it is not full-text indexed 无法在列“ t_name”上使用CONTAINS或FREETEXT谓词,因为它不是全文索引

The second one trows an error, because you are not selecting from the table with the full text index, but from a derived table . 第二个引发错误,因为您不是从具有全文索引的表中进行选择,而是从派生表中进行选择 The engine can't move the full text search from the outer select to the inner one. 引擎无法将全文搜索从外部选择项移到内部选择项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM