Using the Index Server to create query page in Asp.net

Source: Internet
Author: User

Today I was Ed 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 cocould query Index ServerIn the same mannerThat they wowouldQuery 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 particle 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 shoshould 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.

 

I am tired of speaking English for half a day. Let's talk about the core of this function. I am most concerned about the phrase "developers cocould query Index Server in the same manner that they wocould query a Database. What does it mean?

 

1. According to the same access method as the relational database, where is the database?

See Data Source = '"+ strcatalog +"' "; // It is the data source.

Data Source Access Method provider = msidxs.1;

Strcatalog is the system and web you see in Index Service. This is the directory that has been created by the operating system. Of course, you can create your own catalog, which is equivalent to creating a database.

2. What to query? How to Write the query statement.

Looking at the defined strquery, my understanding seems to be that there is a table in this database with these fixed fields, such as the file name, path, size, and other information, if you use a SQL Server self-built function scope () and so on, who has relevant details can share them.

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 );


References:

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

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

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.