您的位置:首页 > 编程语言 > ASP

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

2005-03-08 15:45 726 查看
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[/b] that they would query a database.[/b]

 

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐