Using the Index Server to create Query Page in asp.net

來源:互聯網
上載者:User

Today I received a new task: create a simple aspx page using the Microsoft index server to query. I didn't use it before, so I firstly search some info with the help of google and codeproject website.

 

According to the resources on the internet, to create search pages and result pages there are two ways to do this. One is using use fairly simple IDQ and HTX files. The other one is using Asp.net with the help of ADO.Net.

 

With Index server, developers could query index server in the same manner that they would query a database.

 

Some important things to consider basically:

1 consider what document properties and meta-data the user can search

2 how those results are to be displayed.

3 to limit their search to a particular scope

4 how results are sorted and how many appear on a page

 

In fact, these four points are so simple to design. With the help of TextBox, Button, DataGrid control, you can do it easily. Here is my Demo code.

 

Before running the code, firstly you should configure the Index Service.

1. Click Start, and then click Control Panel.

2. Double-click Administrative Tools.

3. Click Computer management.

4. Expand Services and Applications.

 

The detailed operation steps is from Microsoft KB .

 

說了半天英文,好累。說說這個功能的核心,這句話“developers could query index server in the same manner that they would query a database”我最最關心了。什麼意思呢?

 

1、按照與關聯式資料庫相同的訪問方式,那麼資料庫在哪裡?

看Data Source='" + strCatalog + "'";  // 就是資料來源。

資料來源的訪問方式 Provider=MSIDXS.1;

strCatalog 就是你在Index Service 下看到的System, Web ,這個是作業系統已經建立好的目錄,當然你還可以建立自己的Catalog,就相當於建立一個資料庫。

2、查詢什麼,那麼查詢語句如何寫呢。

看看定義的strQuery ,我的理解好像就是這個資料庫裡有1張表,有這些固定的欄位,例如檔案名稱、路徑、大小等資訊,使用了一個SQL Server自建的函數SCOPE()等等,誰有相關的詳細資料,可以共用共用。

string strCatalog,strQuery,connString   ;

                strCatalog = "TestCatalog";

                strQuery = "Select DocTitle,Filename,Size,PATH,URL from SCOPE() where FREETEXT('" +TextBox1.Text.Trim()+ "')";

                connString = "Provider=MSIDXS.1;Integrated Security .='';Data Source='" + strCatalog + "'";


                OleDbConnection1.ConnectionString = connString;

                OleDbDataAdapter OleDbDataAdapter1 = new OleDbDataAdapter(strQuery,OleDbConnection1);


   

參考資料:

http://support.microsoft.com/kb/820105/EN-US/

http://support.microsoft.com/kb/308202

http://www.codeproject.com/aspnet/search.asp#xx982415xx

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.