Search Lite for ASP.NET is designed primarily to be a web-site indexer, and includes a web-site spider/crawler that visits web-sites from a users perspective. This product can also search documents on local drives using the file-system. To do this, we need to programmatically add documents to the index, and then build the index as usual. 1) You will scan directories to identify files that should be indexed
2) You'll programmatically add these files to the index
3) You'll build the index programmatically and then you can run searches (programmatically or from the web control)
In the following code we reference our demo project "Programmatic_VB.NET" which is installed with the main product, this gives you the simple framework to run builds and searches within.
Now go through 1, 2 and 3 from above:
1. Scanning directories for documents to add, in this code we will search for all PDF and Word docs.
i) add a button to the form in the demo and attach an event handler for it's click
ii) add this method
Public Sub FindDocs(ByVal theFoundItems As ArrayList, ByVal theRoot As String)
Dim theDirectories() As String = System.IO.Directory.GetDirectories(theRoot) For Each theDirectory As String In theDirectories FindDocs(theFoundItems, theDirectory) Next
' Now scan the files in the current directory for any that match... Dim theFiles() As String = System.IO.Directory.GetFiles(theRoot)
For Each theFile As String In theFiles If theFile.ToLower().IndexOf(".pdf") > -1 Or theFile.ToLower().IndexOf(".doc") > -1 Then 'PDF & DOC FILE FILTER theFoundItems.Add(theFile) End If Next
End Sub
and use it from your button click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim docs As New ArrayList FindDocs(docs, "C:\Inetpub\wwwroot") 'docs now has paths to all Doc and PDF files under wwwroot (careful, this method can take a long time)
End Sub
2. Add the docs to the index by modifying the Button1_Click to include
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim docs As New ArrayList FindDocs(docs, "C:\Inetpub\wwwroot") 'docs now has paths to all Doc and PDF files under wwwroot (careful, this method can take a long time) 'add the docs to the index Keyoti.SearchEngine.Configuration.xmlLocation = indexDir
Try indexer.Open() Dim doc As String For Each doc In docs indexer.AddDocument(New Keyoti.SearchEngine.Documents.Document(New Keyoti.SearchEngine.DataAccess.DocumentRecord(New Uri(doc)))) Next indexer.Close() Catch ex As Exception MessageBox.Show(("An error occurred: " + ex.Message)) End Try MessageBox.Show("Recursive find ended")
'call UpdateKnownDocs() to refresh list of docs in index UpdateKnownDocs() End Sub
3. Now the index can be built, in the demo this is already taken care of with the Build Index button, it just calls
Sub RunBuild() builderFinished = False Keyoti.SearchEngine.Configuration.xmlLocation = indexDir
Try indexer.Open() indexer.Build() indexer.Close() Catch e As Exception MessageBox.Show(("An error occurred: " + e.Message)) End Try
builderFinished = True Me.stopBuildBT.Enabled = False Me.indexBT.Enabled = True MessageBox.Show("Build ended") End Sub
That will add all the docs/pdfs it can find to the index, once you've built the index you can run searches programmatically (see demo) or using the SearchResult control by pointing it's IndexDirectory property at the directory where you built this index.
Caveats; 1. recursively searching an entire hard drive can take time, so limit paths as much as possible
Complete modified code from demo project (just replace Form1 in the demo with this): Public Class Form1Inherits System.Windows.Forms.Form Dim spider As New Keyoti.SearchEngine.Index.WebSiteSpiderDim indexer As New Keyoti.SearchEngine.Index.DocumentIndexDim indexDir As String = "..\IndexDirectory"Dim crawlerFinished, builderFinished As Boolean '-TOOL METHODS# Region "Crawl"Private Sub crawlBT_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles crawlBT.Click'start crawl the threadDim crawlThread As New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf RunCrawl))crawlThread.Start() 'start the progress threadDim crawlProgressThread As New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf RunCrawlUpdater))crawlProgressThread.Start() Me.stopCrawlBT.Enabled = TrueMe.crawlBT.Enabled = FalseEnd Sub 'crawlBT_Click Sub RunCrawl()crawlerFinished = FalseKeyoti.SearchEngine.Configuration.xmlLocation = indexDir Tryspider.Open() spider.Crawl( New ArrayList(New String() {Me.crawlURLTB.Text}))spider.Close() Catch e As ExceptionMessageBox.Show(("An error occurred: " + e.Message)) End TrycrawlerFinished = TrueMe.stopCrawlBT.Enabled = FalseMe.crawlBT.Enabled = TrueMessageBox.Show("Crawl ended") UpdateKnownDocs() End Sub 'RunCrawl 'updates the UI with crawl progressSub RunCrawlUpdater()While Not crawlerFinishedSystem.Threading.Thread.Sleep(100) Me.crawlProgress.Text = spider.NewLinkNo & " new of " & spider.ProcessedLinkNo & " links"End WhileEnd Sub 'RunCrawlUpdater 'stops the crawlPrivate Sub stopCrawlBT_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles stopCrawlBT.ClickKeyoti.SearchEngine.Index.WebSiteSpider.cancelCrawl = TrueEnd Sub 'stopCrawlBT_Click# End Region# Region "Delete"Private Sub deleteIndexBT_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles deleteIndexBT.ClickMe.deleteIndexBT.Enabled = FalseMe.deleteIndexBT.Text = "Deleting..."Dim delThread As New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf RunDelete))delThread.Start() End Sub 'deleteIndexBT_Click Sub RunDelete()Keyoti.SearchEngine.Configuration.xmlLocation = indexDir Dim ind As New Keyoti.SearchEngine.Index.DocumentIndexind.Open() Dim docs As ArrayList = ind.GetIndexedDocuments()Dim doc As Keyoti.SearchEngine.Documents.DocumentFor Each doc In docsind.RemoveDocument(doc.URI.ToString()) Next docind.Close() Me.deleteIndexBT.Enabled = TrueMe.deleteIndexBT.Text = "Delete"MessageBox.Show("Index deleted") UpdateKnownDocs() End Sub 'RunDelete# End Region# Region "Build Index"Private Sub indexBT_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles indexBT.Click'start build the threadDim buildThread As New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf RunBuild))buildThread.Start() 'start the progress threadDim buildProgressThread As New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf RunBuildUpdater))buildProgressThread.Start() Me.stopBuildBT.Enabled = TrueMe.indexBT.Enabled = FalseEnd Sub 'indexBT_Click Sub RunBuild()builderFinished = FalseKeyoti.SearchEngine.Configuration.xmlLocation = indexDir Tryindexer.Open() indexer.Build() indexer.Close() Catch e As ExceptionMessageBox.Show(("An error occurred: " + e.Message)) End TrybuilderFinished = TrueMe.stopBuildBT.Enabled = FalseMe.indexBT.Enabled = TrueMessageBox.Show("Build ended") End Sub 'RunBuild 'updates the UI with build progressSub RunBuildUpdater()While Not builderFinishedSystem.Threading.Thread.Sleep(100) If indexer.Progress < 100 ThenbuildProgress.Text = indexer.Progress & "% built" ElsebuildProgress.Text = indexer.OccurrenceCount & " indexed - saving..." End IfEnd WhilebuildProgress.Text = "Finished" End Sub 'RunBuildUpdater Private Sub stopBuildBT_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles stopBuildBT.ClickKeyoti.SearchEngine.Index.DocumentIndex.cancelBuild = TrueEnd Sub 'stopBuildBT_Click# End Region# Region "Search"Private Sub searchBT_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles searchBT.ClickKeyoti.SearchEngine.Configuration.xmlLocation = indexDir TryDim resultsOutput As String = ""Dim sa As New Keyoti.SearchEngine.Search.SearchAgentsa.QueryString = Me.queryTB.Textsa.LicenseKey = Me.licenseTB.Text'get first 50 results onlyDim results As Keyoti.SearchEngine.Search.SearchResult = sa.Search(1, 50)Dim item As Keyoti.SearchEngine.Search.ResultItemFor Each item In resultsresultsOutput += item.URIString + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf Next itemIf results.Count = 0 ThenresultsOutput = "No results found" End IfMe.resultsTB.Text = resultsOutputCatch ex As ExceptionMessageBox.Show(("An error occurred: " + ex.Message)) End TryEnd Sub 'searchBT_Click# End Region# Region "E.t.c."Private Sub checkBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles checkBox1.CheckedChangedKeyoti.SearchEngine.Configuration.logging = Me.checkBox1.CheckedEnd Sub 'checkBox1_CheckedChanged Sub UpdateKnownDocs()Keyoti.SearchEngine.Configuration.xmlLocation = indexDir TryDim output As String = ""indexer.Open() Dim docs As ArrayList = indexer.GetIndexedDocuments()Dim doc As Keyoti.SearchEngine.Documents.DocumentFor Each doc In docsoutput += doc.URI.ToString() + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf Next docindexer.Close() If docs.Count = 0 Thenoutput = "No documents in index" End IfMe.knownDocsTB.Text = outputCatch e As ExceptionMessageBox.Show(("An error occurred: " + e.Message)) End TryEnd Sub 'UpdateKnownDocs# End Region # Region " Windows Form Designer generated code "Public Sub New()MyBase.New()'This call is required by the Windows Form Designer.InitializeComponent() 'Add any initialization after the InitializeComponent() callEnd Sub'Form overrides dispose to clean up the component list.Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)If disposing ThenIf Not (components Is Nothing) Thencomponents.Dispose() End IfEnd IfMyBase.Dispose(disposing)End Sub'Required by the Windows Form DesignerPrivate components As System.ComponentModel.IContainer'NOTE: The following procedure is required by the Windows Form Designer'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.Friend WithEvents checkBox1 As System.Windows.Forms.CheckBoxFriend WithEvents deleteIndexBT As System.Windows.Forms.ButtonFriend WithEvents groupBox3 As System.Windows.Forms.GroupBoxFriend WithEvents label3 As System.Windows.Forms.LabelFriend WithEvents licenseTB As System.Windows.Forms.TextBoxFriend WithEvents resultsTB As System.Windows.Forms.TextBoxFriend WithEvents label2 As System.Windows.Forms.LabelFriend WithEvents queryTB As System.Windows.Forms.TextBoxFriend WithEvents searchBT As System.Windows.Forms.ButtonFriend WithEvents groupBox2 As System.Windows.Forms.GroupBoxFriend WithEvents stopBuildBT As System.Windows.Forms.ButtonFriend WithEvents buildProgress As System.Windows.Forms.LabelFriend WithEvents indexBT As System.Windows.Forms.ButtonFriend WithEvents groupBox1 As System.Windows.Forms.GroupBoxFriend WithEvents label4 As System.Windows.Forms.LabelFriend WithEvents stopCrawlBT As System.Windows.Forms.ButtonFriend WithEvents crawlProgress As System.Windows.Forms.LabelFriend WithEvents crawlBT As System.Windows.Forms.ButtonFriend WithEvents crawlURLTB As System.Windows.Forms.TextBoxFriend WithEvents knownDocsTB As System.Windows.Forms.TextBoxFriend WithEvents label1 As System.Windows.Forms.LabelFriend WithEvents Button1 As System.Windows.Forms.Button<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()Me.checkBox1 = New System.Windows.Forms.CheckBoxMe.deleteIndexBT = New System.Windows.Forms.ButtonMe.groupBox3 = New System.Windows.Forms.GroupBoxMe.label3 = New System.Windows.Forms.LabelMe.licenseTB = New System.Windows.Forms.TextBoxMe.resultsTB = New System.Windows.Forms.TextBoxMe.label2 = New System.Windows.Forms.LabelMe.queryTB = New System.Windows.Forms.TextBoxMe.searchBT = New System.Windows.Forms.ButtonMe.groupBox2 = New System.Windows.Forms.GroupBoxMe.stopBuildBT = New System.Windows.Forms.ButtonMe.buildProgress = New System.Windows.Forms.LabelMe.indexBT = New System.Windows.Forms.ButtonMe.groupBox1 = New System.Windows.Forms.GroupBoxMe.label4 = New System.Windows.Forms.LabelMe.stopCrawlBT = New System.Windows.Forms.ButtonMe.crawlProgress = New System.Windows.Forms.LabelMe.crawlBT = New System.Windows.Forms.ButtonMe.crawlURLTB = New System.Windows.Forms.TextBoxMe.knownDocsTB = New System.Windows.Forms.TextBoxMe.label1 = New System.Windows.Forms.LabelMe.Button1 = New System.Windows.Forms.ButtonMe.groupBox3.SuspendLayout()Me.groupBox2.SuspendLayout()Me.groupBox1.SuspendLayout()Me.SuspendLayout()''checkBox1'Me.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.checkBox1.Location = New System.Drawing.Point(112, 40)Me.checkBox1.Name = "checkBox1"Me.checkBox1.TabIndex = 12Me.checkBox1.Text = "Logging"''deleteIndexBT'Me.deleteIndexBT.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.deleteIndexBT.Location = New System.Drawing.Point(16, 40)Me.deleteIndexBT.Name = "deleteIndexBT"Me.deleteIndexBT.Size = New System.Drawing.Size(80, 23)Me.deleteIndexBT.TabIndex = 11Me.deleteIndexBT.Text = "Delete index"''groupBox3'Me.groupBox3.Controls.Add(Me.label3)Me.groupBox3.Controls.Add(Me.licenseTB)Me.groupBox3.Controls.Add(Me.resultsTB)Me.groupBox3.Controls.Add(Me.label2)Me.groupBox3.Controls.Add(Me.queryTB)Me.groupBox3.Controls.Add(Me.searchBT)Me.groupBox3.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.groupBox3.Location = New System.Drawing.Point(424, 72)Me.groupBox3.Name = "groupBox3"Me.groupBox3.Size = New System.Drawing.Size(496, 472)Me.groupBox3.TabIndex = 10Me.groupBox3.TabStop = FalseMe.groupBox3.Text = "Search"''label3'Me.label3.Location = New System.Drawing.Point(16, 64)Me.label3.Name = "label3"Me.label3.Size = New System.Drawing.Size(72, 23)Me.label3.TabIndex = 5Me.label3.Text = "License key:"''licenseTB'Me.licenseTB.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))Me.licenseTB.Location = New System.Drawing.Point(104, 64)Me.licenseTB.Name = "licenseTB"Me.licenseTB.Size = New System.Drawing.Size(376, 18)Me.licenseTB.TabIndex = 4Me.licenseTB.Text = "5550655C6258645D665768675F5864364E4F3E3C363C3E393F3B414041484048494D4B1"''resultsTB'Me.resultsTB.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))Me.resultsTB.Location = New System.Drawing.Point(16, 104)Me.resultsTB.Multiline = TrueMe.resultsTB.Name = "resultsTB"Me.resultsTB.ScrollBars = System.Windows.Forms.ScrollBars.VerticalMe.resultsTB.Size = New System.Drawing.Size(472, 360)Me.resultsTB.TabIndex = 3Me.resultsTB.Text = "Results:"''label2'Me.label2.Location = New System.Drawing.Point(16, 24)Me.label2.Name = "label2"Me.label2.Size = New System.Drawing.Size(80, 23)Me.label2.TabIndex = 2Me.label2.Text = "Search query:"''queryTB'Me.queryTB.Location = New System.Drawing.Point(104, 24)Me.queryTB.Name = "queryTB"Me.queryTB.Size = New System.Drawing.Size(296, 20)Me.queryTB.TabIndex = 1Me.queryTB.Text = ""''searchBT'Me.searchBT.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.searchBT.Location = New System.Drawing.Point(408, 24)Me.searchBT.Name = "searchBT"Me.searchBT.Size = New System.Drawing.Size(80, 23)Me.searchBT.TabIndex = 0Me.searchBT.Text = "Search"''groupBox2'Me.groupBox2.Controls.Add(Me.stopBuildBT)Me.groupBox2.Controls.Add(Me.buildProgress)Me.groupBox2.Controls.Add(Me.indexBT)Me.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.groupBox2.Location = New System.Drawing.Point(8, 464)Me.groupBox2.Name = "groupBox2"Me.groupBox2.Size = New System.Drawing.Size(408, 80)Me.groupBox2.TabIndex = 9Me.groupBox2.TabStop = FalseMe.groupBox2.Text = "Index"''stopBuildBT'Me.stopBuildBT.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.stopBuildBT.Location = New System.Drawing.Point(320, 48)Me.stopBuildBT.Name = "stopBuildBT"Me.stopBuildBT.Size = New System.Drawing.Size(80, 23)Me.stopBuildBT.TabIndex = 2Me.stopBuildBT.Text = "Stop Build"''buildProgress'Me.buildProgress.Location = New System.Drawing.Point(16, 24)Me.buildProgress.Name = "buildProgress"Me.buildProgress.Size = New System.Drawing.Size(296, 48)Me.buildProgress.TabIndex = 1''indexBT'Me.indexBT.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.indexBT.Location = New System.Drawing.Point(320, 16)Me.indexBT.Name = "indexBT"Me.indexBT.Size = New System.Drawing.Size(80, 23)Me.indexBT.TabIndex = 0Me.indexBT.Text = "Build Index"''groupBox1'Me.groupBox1.Controls.Add(Me.label4)Me.groupBox1.Controls.Add(Me.stopCrawlBT)Me.groupBox1.Controls.Add(Me.crawlProgress)Me.groupBox1.Controls.Add(Me.crawlBT)Me.groupBox1.Controls.Add(Me.crawlURLTB)Me.groupBox1.Controls.Add(Me.knownDocsTB)Me.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.groupBox1.Location = New System.Drawing.Point(8, 72)Me.groupBox1.Name = "groupBox1"Me.groupBox1.Size = New System.Drawing.Size(408, 384)Me.groupBox1.TabIndex = 8Me.groupBox1.TabStop = FalseMe.groupBox1.Text = "Crawl"''label4'Me.label4.Location = New System.Drawing.Point(16, 72)Me.label4.Name = "label4"Me.label4.Size = New System.Drawing.Size(288, 16)Me.label4.TabIndex = 5Me.label4.Text = "Documents in database"''stopCrawlBT'Me.stopCrawlBT.Enabled = FalseMe.stopCrawlBT.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.stopCrawlBT.Location = New System.Drawing.Point(320, 56)Me.stopCrawlBT.Name = "stopCrawlBT"Me.stopCrawlBT.Size = New System.Drawing.Size(80, 23)Me.stopCrawlBT.TabIndex = 4Me.stopCrawlBT.Text = "Stop Crawl"''crawlProgress'Me.crawlProgress.Location = New System.Drawing.Point(16, 48)Me.crawlProgress.Name = "crawlProgress"Me.crawlProgress.Size = New System.Drawing.Size(296, 24)Me.crawlProgress.TabIndex = 3''crawlBT'Me.crawlBT.FlatStyle = System.Windows.Forms.FlatStyle.SystemMe.crawlBT.Location = New System.Drawing.Point(320, 24)Me.crawlBT.Name = "crawlBT"Me.crawlBT.Size = New System.Drawing.Size(80, 23)Me.crawlBT.TabIndex = 2Me.crawlBT.Text = "Start Crawl"''crawlURLTB'Me.crawlURLTB.Location = New System.Drawing.Point(16, 24)Me.crawlURLTB.Name = "crawlURLTB"Me.crawlURLTB.Size = New System.Drawing.Size(296, 20)Me.crawlURLTB.TabIndex = 1Me.crawlURLTB.Text = "http://localhost/KeyotiSearchDemo_VB"''knownDocsTB'Me.knownDocsTB.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))Me.knownDocsTB.Location = New System.Drawing.Point(16, 96)Me.knownDocsTB.Multiline = TrueMe.knownDocsTB.Name = "knownDocsTB"Me.knownDocsTB.ReadOnly = TrueMe.knownDocsTB.ScrollBars = System.Windows.Forms.ScrollBars.BothMe.knownDocsTB.Size = New System.Drawing.Size(384, 280)Me.knownDocsTB.TabIndex = 3Me.knownDocsTB.Text = "Known documents"Me.knownDocsTB.WordWrap = False''label1'Me.label1.Location = New System.Drawing.Point(8, 8)Me.label1.Name = "label1"Me.label1.Size = New System.Drawing.Size(688, 32)Me.label1.TabIndex = 7Me.label1.Text = "This demo is intended to give an overview of how to programmatically work with th" & _"e search engine, it is not a user friendly indexing tool Please run Crawl, then " & _ "Build and then Search" ''Button1'Me.Button1.Location = New System.Drawing.Point(328, 40)Me.Button1.Name = "Button1"Me.Button1.TabIndex = 13Me.Button1.Text = "Button1"''Form1'Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)Me.ClientSize = New System.Drawing.Size(928, 555)Me.Controls.Add(Me.Button1)Me.Controls.Add(Me.checkBox1)Me.Controls.Add(Me.deleteIndexBT)Me.Controls.Add(Me.groupBox3)Me.Controls.Add(Me.groupBox2)Me.Controls.Add(Me.groupBox1)Me.Controls.Add(Me.label1)Me.Name = "Form1"Me.Text = "Form1"Me.groupBox3.ResumeLayout(False)Me.groupBox2.ResumeLayout(False)Me.groupBox1.ResumeLayout(False)Me.ResumeLayout(False)End Sub# End RegionSub on_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.LoadUpdateKnownDocs() End Sub<STAThread()> _ Shared Sub Main()Application.EnableVisualStyles() Application.Run( New Form1)End Sub Public Sub FindDocs(ByVal theFoundItems As ArrayList, ByVal theRoot As String)Dim theDirectories() As String = System.IO.Directory.GetDirectories(theRoot)For Each theDirectory As String In theDirectoriesFindDocs(theFoundItems, theDirectory) Next' Now scan the files in the current directory for any that match... Dim theFiles() As String = System.IO.Directory.GetFiles(theRoot)For Each theFile As String In theFilesIf theFile.ToLower().IndexOf(".pdf") > -1 Or theFile.ToLower().IndexOf(".doc") > -1 ThentheFoundItems.Add(theFile) End IfNextEnd Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim docs As New ArrayListFindDocs(docs, "C:\Inetpub\wwwroot") 'docs now has paths to all Doc and PDF files under wwwroot (careful, this method can take a long time)'add the docs to the indexKeyoti.SearchEngine.Configuration.xmlLocation = indexDir Tryindexer.Open() Dim doc As StringFor Each doc In docsindexer.AddDocument( New Keyoti.SearchEngine.Documents.Document(New Keyoti.SearchEngine.DataAccess.DocumentRecord(New Uri(doc))))Nextindexer.Close() Catch ex As ExceptionMessageBox.Show(("An error occurred: " + ex.Message)) End TryMessageBox.Show("Recursive find ended") 'call UpdateKnownDocs() to refresh list of docs in indexUpdateKnownDocs() End SubEnd Class
|