SQLServer联机帮助帮助里面将contains和fulltext函数都提到过 如下: 使用 FREETEXT 谓词 使用 FREETEXT 谓词可以输入单词或短语的任意集合,甚至一个完整的句子。全文查询引擎将检查该文本,标识出所有重要的单词和名词短语,并用这些条件在内部构造一个查询。此例使用 FREETEXT 谓词查询名为 description 的一列。 FREETEXT (description, ' "The Fulton County Grand Jury said Friday an investigation 下面来自联机帮助关于全文索引的实例,用于pub数据库: USE pubs -- Create and populate a table. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'FulltextTest') DROP TABLE FulltextTest GO CREATE TABLE FulltextTest ( article_id int IDENTITY(100,1) CONSTRAINT PK_title_id PRIMARY KEY, article_title nvarchar(200) ) GO INSERT FulltextTest (article_title) VALUES (N'Steven Buchanan has always enjoyed ice skating.') INSERT FulltextTest (article_title) VALUES (N'Elvis Stoiko: The best male figure skater') INSERT FulltextTest (article_title) VALUES (N'Steven Buchanan On Ice: Skating Reaches Tops in Public Opinion Poll') INSERT FulltextTest (article_title) VALUES (N'Last night, Steven Buchanan skated on the ice!! Skating fans cheer!') INSERT FulltextTest (article_title) VALUES (N'Ice-skating brings out the best in Steven. Buchanan exults in first victory...') GO-- Enable full-text searching in the database. EXEC sp_fulltext_database 'enable' GO-- Create a new full-text catalog. EXEC sp_fulltext_catalog 'StevenBCatalog', 'create' GO-- Register the new table and column within it for full-text querying, -- then activate the table. EXEC sp_fulltext_table 'FulltextTest', 'create', 'StevenBCatalog', 'PK_title_id' EXEC sp_fulltext_column 'FulltextTest', 'article_title', 'add' EXEC sp_fulltext_table 'FulltextTest', 'activate' GO-- Start full population of the full-text catalog. Note that it is -- asynchronous, so delay must be built in if populating a -- large index.EXEC sp_fulltext_catalog 'StevenBCatalog', 'start_full' -- Execute a full-text query against the new table. SELECT article_title FROM FulltextTest WHERE CONTAINS(article_title, ' "Steven Buchanan" AND "ice skating" ')帮助上说会最后显示: article_title ------------------------------------------------------------------------ Steven Buchanan has always enjoyed ice skating. Last night, Steven Buchanan skated on the ice!! Skating fans cheer! Steven Buchanan On Ice: Skating Reaches Tops in Public Opinion Poll Ice-skating brings out the best in Steven. Buchanan exults in first victory... (4 row(s) affected)而我这里还是没有检索到。 没想到帮助上面的实例都通不过,真是郁闷...
如下:
使用 FREETEXT 谓词
使用 FREETEXT 谓词可以输入单词或短语的任意集合,甚至一个完整的句子。全文查询引擎将检查该文本,标识出所有重要的单词和名词短语,并用这些条件在内部构造一个查询。此例使用 FREETEXT 谓词查询名为 description 的一列。
FREETEXT (description, ' "The Fulton County Grand Jury said Friday an investigation 下面来自联机帮助关于全文索引的实例,用于pub数据库:
USE pubs
-- Create and populate a table.
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'FulltextTest')
DROP TABLE FulltextTest
GO
CREATE TABLE FulltextTest
( article_id int IDENTITY(100,1)
CONSTRAINT PK_title_id PRIMARY KEY,
article_title nvarchar(200)
)
GO
INSERT FulltextTest (article_title) VALUES (N'Steven Buchanan has always enjoyed ice skating.')
INSERT FulltextTest (article_title) VALUES (N'Elvis Stoiko: The best male figure skater')
INSERT FulltextTest (article_title) VALUES (N'Steven Buchanan On Ice: Skating Reaches Tops in Public Opinion Poll')
INSERT FulltextTest (article_title) VALUES (N'Last night, Steven Buchanan skated on the ice!! Skating fans cheer!')
INSERT FulltextTest (article_title) VALUES (N'Ice-skating brings out the best in Steven. Buchanan exults in first victory...')
GO-- Enable full-text searching in the database.
EXEC sp_fulltext_database 'enable'
GO-- Create a new full-text catalog.
EXEC sp_fulltext_catalog 'StevenBCatalog',
'create'
GO-- Register the new table and column within it for full-text querying,
-- then activate the table.
EXEC sp_fulltext_table 'FulltextTest',
'create',
'StevenBCatalog',
'PK_title_id'
EXEC sp_fulltext_column 'FulltextTest',
'article_title',
'add'
EXEC sp_fulltext_table 'FulltextTest',
'activate'
GO-- Start full population of the full-text catalog. Note that it is
-- asynchronous, so delay must be built in if populating a
-- large index.EXEC sp_fulltext_catalog 'StevenBCatalog',
'start_full'
-- Execute a full-text query against the new table.
SELECT article_title
FROM FulltextTest
WHERE CONTAINS(article_title, ' "Steven Buchanan" AND "ice skating" ')帮助上说会最后显示:
article_title
------------------------------------------------------------------------
Steven Buchanan has always enjoyed ice skating.
Last night, Steven Buchanan skated on the ice!! Skating fans cheer!
Steven Buchanan On Ice: Skating Reaches Tops in Public Opinion Poll
Ice-skating brings out the best in Steven. Buchanan exults in first victory...
(4 row(s) affected)而我这里还是没有检索到。
没想到帮助上面的实例都通不过,真是郁闷...