全文本檢索的應用(1)

來源:互聯網
上載者:User

 

 

基本知識
1. SQL Server7 的 DeskTop 版中沒有全文本檢索。
2. 一個表只能有一個全文本檢索。
3. 被檢索的表必須有單列的唯一索引。
4. 全文本的索引儲存在檔案系統中,而非資料庫中。
5. 更新全文本索引的過程比常規索引要耗時,而且也不象常規索引那樣可以由資料庫系統立即更新。
6. 全文本索引包含在全文本目錄( Full-Text Catalog )中,每個資料庫可以包含一個或多個目錄,但一個目錄不能屬於多個資料庫。
7. 全文本檢索只能在真正的表上建立,不能是視圖,系統資料表,暫存資料表。
8. 全文本檢索會忽略某些噪音字( noise words),比如英文的 a,the,and,中文的'和','是'等等。
9. 如果在查詢中包含 noise words ,就會引發錯誤,在應用程式中應去除這些 noise words。

啟動全文本檢索服務。
方法A:在企業管理器中開啟 Support Services 檔案夾,在 Full-Text Search 的右鍵菜單中選擇 Start。
方法B:在 SQL Server Service Manager 的 Services 下拉式清單中選擇 Microsoft Search,並單擊 Start/Continue 按鈕。
方法C:使用 net start mssearch 的命令列方式。
使用全文本檢索嚮導( Full-Text Indexing Wizard )。
step1. 選擇被檢索的資料庫,在 Tools 的菜單中,選擇 Full-text Indexing,進入歡迎( Welcome )的螢幕,單擊 next。
step2. 選擇被檢索的表,單擊 next。
step3. 選擇唯一索引,單擊 next。
step4. 選擇被索引的列,單擊 Add,該列顯示在右欄中。單擊 next。
step5. 選擇目錄(選擇已存在的目錄,或建立新的目錄),單擊 next。
step6. 選擇或建立 population schedule(可選項),單擊 next。
step7. 單擊 finish。
使用 SQL-DMO (以 VB 為例)
step1. 在工程的引用中選擇 Microsoft SQLDMO Object Library。
step2. 建立 SQLServer 對象。
Dim objSQL As New SQLDMO.SQLServer
objSQL.Connect "localhost", "sa", ""
step3. 建立新的目錄,並加入到被索引的資料庫目錄中。
Dim objCatalog As New SQLDMO.FullTextCatalog
'使 pubs 為全文本檢索的資料庫
objSQL.Databases("pubs").EnableFullTextCatalogs
'建立新的目錄
objCatalog.Name = "ftcPubsTest"
'將新目錄加入到目錄集合中
objSQL.Databases("pubs").FullTextCatalogs.Add objCatalog
step4. 在表上建立全文本索引。
Dim objTable As New SQLDMO.Table
'指定被索引的表
Set objTable = objSQL.Databases("pubs").Tables("authors")
'指定目錄名和唯一索引名
objTable.FullTextCatalogName = "ftcPubsTest"
objTable.UniqueIndexForFullText = "UPKCL_auidind"
objTable.FullTextIndex = True

'指定被索引的列
objTable.Columns("au_lname").FullTextIndex = True
objTable.Columns("au_fname").FullTextIndex = True

'啟用該表上的全文本索引
objTable.FullTextIndexActive = True

step5. 啟動全文本目錄
objCatalog.Start SQLDMOFullText_Full
使用預存程序
step1. 使 pubs 為全文本檢索的資料庫
USE Pubs
go
sp_fulltext_database 'enable'

step2. 建立新的目錄
sp_fulltext_catalog 'ftcPubsTest','create'
step3. 指定被索引的表
sp_fulltext_table 'authors','create','ftcPubsTest','UPKCL_auidind'
step4. 指定被索引的列
sp_fulltext_column 'authors','au_lname','add'
sp_fulltext_column 'authors','au_fname','add'
step5. 啟用該表上的全文本索引
sp_fulltext_table 'authors','activate'
step6. 啟動全文本目錄
sp_fulltext_catalog 'ftcPubsTest','start_full'

http://www.csdn.net/develop/read_article.asp?id=8894 

http://www.csdn.net/develop/read_article.asp?id=8894



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.