不能在表或索引视图上使用 CONTAINS 或 FREETEXT 谓词,因为它不是全文索引
我的 SQL Server 2008 R2 数据库出现以下错误:
I am getting following error in my SQL server 2008 R2 database:
不能在表或索引视图 'tblArmy' 上使用 CONTAINS
或 FREETEXT
谓词,因为它不是全文索引.
Cannot use a
CONTAINS
orFREETEXT
predicate on table or indexed view 'tblArmy' because it is not full-text indexed.
推荐答案
- 确保您已安装全文搜索功能.
创建全文搜索目录(如果需要)
首先检查目录是否已经存在
First check if any catalog already exists
select *
from sys.fulltext_catalogs
如果没有找到目录,创建一个
If no catalog is found create one
use [DatabaseName]
create fulltext catalog FullTextCatalog as default
您可以验证目录是否以与上述相同的方式创建
you can verify that the catalog was created in the same way as above
创建全文搜索索引.
create fulltext index on Production.ProductDescription(Description)
key index PK_ProductDescription_ProductDescriptionID
在创建索引之前,请确保:
- 您还没有在表格上设置全文搜索索引,因为一张表格上只允许有一个全文搜索索引
- 表上存在唯一索引.索引必须基于单键列,不允许 NULL.
- 存在全文目录.如果没有默认的全文目录,则必须明确指定全文目录名称.
Before you create the index, make sure:
- you don't already have full-text search index on the table as only one full-text search index allowed on a table
- a unique index exists on the table. The index must be based on single-key column, that does not allow NULL.
- full-text catalog exists. You have to specify full-text catalog name explicitly if there is no default full-text catalog.
您可以在 SQL Sever Management Studio 中执行第 2 步和第 3 步.在对象资源管理器中,右键单击一个表,选择Full-Text index
菜单项,然后选择Define Full-Text Index...
子菜单项.全文索引向导将指导您完成整个过程.如果您还没有全文搜索目录,它还会为您创建一个全文搜索目录.
You can do step 2 and 3 in SQL Sever Management Studio. In object explorer, right click on a table, select Full-Text index
menu item and then Define Full-Text Index...
sub-menu item. Full-Text indexing wizard will guide you through the process. It will also create a full-text search catalog for you if you don't have any yet.
您可以在 MSDN
执行完这些步骤后,您需要几分钟的时间来创建全文搜索索引(这取决于表和列数据的大小)
After following the steps you need a few minutes so that the full text search index is created (this depends on the size of the table and column data)
相关文章