如何在视图上创建全文索引
How to create a fulltext index on a view
我想在我的视图上创建全文索引,但我不能,我也看不出问题所在。
我的唯一聚集索引视图:
-- View Creation
CREATE VIEW View_School_Degree WITH SCHEMABINDING AS
SELECT
s.Id_School [School Id]
,s.Name [School Name]
,s.Type
,s.Code
,CAST(CONCAT(s.Address1, N' ',s.Address2 , N', ', s.Address3, N' ', s.Address4) AS nvarchar(500)) [Postal Address]
,s.Email
,d.Id_Degree [Degree Id]
,d.Title [Degree Title]
,d.[Option] [Degree Option]
,CAST(CONCAT(d.Code, N' / ', d.[Option]) AS [nvarchar]) [Degree / Option]
,sd.Capacity
FROM dbo.School_Degree sd
JOIN dbo.School s ON s.Id_School = sd.Id_School
JOIN dbo.Degree d ON d.Id_Degree = sd.Id_Degree
GO
-- INDEX Creation
CREATE UNIQUE CLUSTERED INDEX [IX_View_School_Degree_Identifier] ON dbo.View_School_Degree
(
[School Id] ASC,
[Degree Id] ASC
)
我使用 FULLTEXT 目录创建 FULLTEXT 索引:
CREATE FULLTEXT CATALOG SchoolCatalog
WITH ACCENT_SENSITIVITY = OFF
AUTHORIZATION dbo;
GO
CREATE FULLTEXT INDEX ON dbo.View_School_Degree
(
[School Name] LANGUAGE 1036
,[Degree Title] LANGUAGE 1036
,[Postal Address] LANGUAGE 1036
)
KEY INDEX IX_View_School_Degree_Identifier
ON SchoolCatalog
WITH STOPLIST OFF;
GO
我收到这个错误:
'IX_View_School_Degree_Identifier' is not a valid index for applying a full-text search key. A full-text search key must be a unique index that does not accept the value Null, has only one column not offline, is not defined on a calculated non-deterministic or imprecise non-persistent column, has no filter, and has a maximum size of 900 bytes. Choose another index for the full text key
如您在错误消息中所见,这部分内容为:
IX_View_School_Degree_Identifier' is not a valid index .... has only one column
但是您的索引是由两列组成的。您需要创建一个满足这些要求的新索引
我想在我的视图上创建全文索引,但我不能,我也看不出问题所在。
我的唯一聚集索引视图:
-- View Creation
CREATE VIEW View_School_Degree WITH SCHEMABINDING AS
SELECT
s.Id_School [School Id]
,s.Name [School Name]
,s.Type
,s.Code
,CAST(CONCAT(s.Address1, N' ',s.Address2 , N', ', s.Address3, N' ', s.Address4) AS nvarchar(500)) [Postal Address]
,s.Email
,d.Id_Degree [Degree Id]
,d.Title [Degree Title]
,d.[Option] [Degree Option]
,CAST(CONCAT(d.Code, N' / ', d.[Option]) AS [nvarchar]) [Degree / Option]
,sd.Capacity
FROM dbo.School_Degree sd
JOIN dbo.School s ON s.Id_School = sd.Id_School
JOIN dbo.Degree d ON d.Id_Degree = sd.Id_Degree
GO
-- INDEX Creation
CREATE UNIQUE CLUSTERED INDEX [IX_View_School_Degree_Identifier] ON dbo.View_School_Degree
(
[School Id] ASC,
[Degree Id] ASC
)
我使用 FULLTEXT 目录创建 FULLTEXT 索引:
CREATE FULLTEXT CATALOG SchoolCatalog
WITH ACCENT_SENSITIVITY = OFF
AUTHORIZATION dbo;
GO
CREATE FULLTEXT INDEX ON dbo.View_School_Degree
(
[School Name] LANGUAGE 1036
,[Degree Title] LANGUAGE 1036
,[Postal Address] LANGUAGE 1036
)
KEY INDEX IX_View_School_Degree_Identifier
ON SchoolCatalog
WITH STOPLIST OFF;
GO
我收到这个错误:
'IX_View_School_Degree_Identifier' is not a valid index for applying a full-text search key. A full-text search key must be a unique index that does not accept the value Null, has only one column not offline, is not defined on a calculated non-deterministic or imprecise non-persistent column, has no filter, and has a maximum size of 900 bytes. Choose another index for the full text key
如您在错误消息中所见,这部分内容为:
IX_View_School_Degree_Identifier' is not a valid index .... has only one column
但是您的索引是由两列组成的。您需要创建一个满足这些要求的新索引