VB.NET 2005 Indexing Service
I've got two questions about Indexing Service with COM.
How can you add an directory to a catalog by code ?
How can you get the state from the indexing process by code ?
i.e. state is 40 %
I will show some code what I did get working:
Dim obj As New CIODMLib.AdminIndexServerClass 'reference to Indexing Service Administration Type Library 1.0
'create catalog
obj.Stop()
obj.AddCatalog("ICT", "D:\ICT_Catalog")
obj.Start()
MessageBox.Show("Succesfully Added")
'get catalogs
Dim isFoundCatalog As Boolean = obj.FindFirstCatalog
Dim sCatalogList As String
While isFoundCatalog
Dim Catalog As CIODMLib.ICatAdm = obj.GetCatalog
sCatalogList &= "Name: " & Catalog.CatalogName & ", "
sCatalogList &= "Loc: " & Catalog.CatalogLocation & ", "
sCatalogList &= "Running: " & Catalog.IsCatalogRunning & ControlChars.NewLine
isFoundCatalog = obj.FindNextCatalog()
End While
MsgBox(sCatalogList)
'find items in catalogs
Dim con As OleDbConnection
Dim cmd As New OleDbCommand
con = New OleDbConnection("Provider=\MSIDXS.1\;Data Source=ICT;Integrated Security .=")
cmd.Connection = con
cmd.CommandText = "select doctitle, filename, vpath, rank, characterization from scope() " & _
" where FREETEXT(Contents, '" + TextBox1.text + "') order by rank desc "
con.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
cmd.ExecuteNonQuery()
Dim ds As DataSet = New DataSet
Dim dt As DataTable = New DataTable
da.Fill(ds, "SearchResult")
dt = ds.Tables(0)
DataGridView1.DataSource = dt
|