通过内部联接在视图上启用全文搜索
我正在运行 Sql Server 2008 R2,我需要在具有内部联接的视图上启用全文搜索。我的问题是我不知道如何创建全文索引。
当我使用全文索引向导时,出现此错误。
必须在此表/视图上定义唯一列。
为了让您更好地理解我的问题,请参阅w3school的以下示例 http://www.w3schools.com/sql /sql_join_inner.asp 最后的选择只是我的观点。
PersonOrderView - View
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
INNER JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName <- Order by is not important for me
Persons - Table
P_Id (PK, int, not null)
LastName(nvarchar(50), null)
FirstName(nvarchar(50), null)
Address(nvarchar(50), null)
City(nvarchar(50), null)
Orders - Table
O_Id(PK, int, not null)
P_Id(FK, int, not null)
OrderNo(nvarchar(50), not null)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只能在 索引视图,这就是您收到错误的原因。要在表或视图上创建全文搜索,它必须具有唯一、单列、不可为空的索引。
换句话说,您应该创建如下所示的视图:
SQL 全文搜索通过称为填充的过程构建全文索引,该过程用单词及其在表和行中出现的位置填充索引。这就是为什么您需要一个字段来唯一标识您的每一行,这就是为什么您需要对视图建立索引。
更多信息此处< /a>.
You can only create a full text index on an indexed view, that is why you are getting the error. To create full-text search on a table or view, it must have a unique, single-column, non-nullable index.
In other words, you should create your view something like this:
SQL full-text search builds a full-text index through a process called population, which fills the index with words and the locations in which they occur in your tables and rows. That is why you need a field that will uniquely identify you each row and that is why you need to make the view indexed.
More information here.