After you create a new catalog, add the folders that you want included in the scope of the catalog. The scope is the set of folders that is included in and excluded from the catalog. The scope defines the content that is included and excluded from the index. For each folder that is included or excluded, all its subfolders are also included or excluded.
Double-click TestCatalog (the catalog that you created in the "Create a Test Folder" section).
Right-click Directories, point to New, and then click Directory.
Click Browse, locate and then click the folder that you want to add (C:\myCatalogFolder\), and then click OK.
In Solution Explorer, right-click WebForm1, and then click View Code. Replace the existing code with the following sample code.
Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid#Region " Web Form Designer Generated Code " 'Web Form Designer requires this call. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: Web Form Designer requires this method call. 'Do not modify it by using the code editor. InitializeComponent() End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strCatalog As String ' Catalog Name strCatalog = "TestCatalog" Dim strQuery As String strQuery = "Select DocTitle,Filename,Size,PATH,URL from SCOPE() where FREETEXT('" & TextBox1.Text & "')" ' TextBox1.Text is word that you type in the text box to query by using Index Service. ' Dim connString As String = "Provider=MSIDXS.1;Integrated Security .='';Data Source='" & strCatalog & "'" Dim cn As New System.Data.OleDb.OleDbConnection(connString) Dim cmd As New System.Data.OleDb.OleDbDataAdapter(strQuery, cn) Dim testDataSet As New DataSet() cmd.Fill(testDataSet) ' Bind DataGrid to the DataSet. DataGrid is the ID for the ' DataGrid control in the HTML section. Dim source As New DataView(testDataSet.Tables(0)) DataGrid1.DataSource = source DataGrid1.DataBind() End SubEnd Class
Indexing Service automatically processes the TestCatalog and prepares a word list for indexing. When you run the sample code, you may not receive the results as expected because Indexing Service requires some time to build the index. To verify the state of the index, click Indexing Service in the right pane, and then verify that the Word List value for TestCatalog is greater than zero. If the Word List value is zero, wait for the index to build the list.
Index Data May Have Become Corrupted
If the search does not return the expected search results when you query the index, the index data may have become corrupted. To troubleshoot this issue, stop and restart Indexing Service to re-index all documents. To do this, follow these steps:
Click Start, point to Settings, and then click Control Panel.
Double-click Administrative Tools, and then double-click Computer Management.
In the console tree, double-click Services and Applications.
Right-click Indexing Service, and then click Stop.
Right-click Indexing Service, and then click Start.