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
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
相关文章推荐
- How to get URL and QueryString value in an ASP.NET page
- HOW TO: Upload a File to a Web Server in ASP.NET by Using Visual Basic .NET
- CodeSnip: How to Get Id of the Record Using ASP.NET and SQL Server 2000
- How to programmatically assign a SkinID to a control while using a master page in ASP.net 2.0
- How to set the DefaultButton in a Page Based on ASP.NET Master Page
- How to programmatically assign a SkinID to a control while using a master page in ASP.net 2.0
- csharp: Export DataTable to Excel using OpenXml 2.5 in asp.net
- How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C# .NET
- dumps the server root page (index.htm) to the screen
- Rewrite the master page form action attribute in asp.net 2.0
- Send and Receive JSON objects to Web Service Methods using jQuery AJAX in ASP.Net
- [转]An introduction to OAuth 2.0 using Facebook in ASP.NET Core
- Saving and Displaying Photos in SQL Server using ASP.NET and FileUpload Control
- Preview Word files (docx) in HTML using ASP.NET, OpenXML and LINQ to XML
- How to Create a Second Level GridView in ASP.NET
- Speeding Up FireFox When Using the ASP.NET Development Server from Localhost
- SQL Server Setup failed to obtain system account information for the ASPNET
- ASP.Net DebugError解决方案[转]:Unable to start debugging on the web server.Debugging failes because integrated Windows authentication is not enabled.
- Downloading files from a server to client, using ASP.Net, when file size is too big for MemoryStream using Generic Handlers (ashx)