Close
dtSearch Engine API for .NET Framework 2.x-4.x 2024.01
Example

This example, from the SpiderDemo sample application, demonstrates how to set up the Spider to index a list of web sites. The dtsIndexCacheText and dtsIndexCacheOriginalFile flags are not necessary to index web sites, but using these flags makes hit-highlighting much faster and easier to implement.

// Make IndexJob indexJob = new IndexJob(); indexJob.ActionCreate = true; indexJob.ActionAdd = true; indexJob.IndexPath = this.IndexPathEdit.Text; indexJob.IndexingFlags = IndexingFlags.dtsIndexCacheText | IndexingFlags.dtsIndexCacheOriginalFile; // Make data source to crawl the web sites listed in webSiteList dataSource = new HttpDataSource(); foreach (WebSite ws in webSiteList) { dataSource.Add(ws); } // Start the Spider dataSource.StartCrawl(); // Attach the Spider's DataSource to the IndexJob indexJob.DataSourceToIndex = dataSource; // Start indexing. The indexer will repeatedly call dataSource.GetNextDoc() to obtain pages // to index until dataSource.GetNextDoc() returns false. indexJob.ExecuteInThread();