Create or update indexes
For more information on creating, updating, and maintaining indexes, see "Building and Maintaining Indexes" in dtSearchApiRef.chm.
To create or update an index, make an IndexJob, use the properties to describe the indexing task you want the engine to perform, and call the Execute method.
IndexJob provides two ways to specify the text to be indexed: (1) the FoldersToIndex, IncludeFilters, and ExcludeFilters members let you specify directories and filename filters identifying a set of disk files to index, and (2) the DataSourceToIndex member lets you supply data directly to the dtSearch Engine for indexing, using an object that implements the DataSource interface. DataSourceToIndex is useful for indexing data from non-file sources such as message stores, SQL databases, dynamically-generated data, or any non-file data accessible to your program.
The Action flags specify the actions you want the engine to perform. If more than one action is specified, the engine will perform the actions in the following order: create, add, removeDeleted, removeListed, compress, merge, verify.
IndexJob requires the IDisposable Pattern.
Set the flag dtsIndexMultithread in an IndexJob to build an index using multiple threads. Set IndexJob.ThreadCount to specify the number of threads to use. The engine will create the threads itself and return from the IndexJob once all of the threads are done.
Index progress notifications will be sent from each thread so the handler for these notifications must be able to handle concurrent notifications from multiple threads.
For indexes built with the DataSource API, a separate DataSource instance must be provided for each thread using DataSourceList. For example, if the thread count is 4, then the IndexJob must include 4 DataSource instances, one for each thread. For sample code demonstrating how to do this, see the FolderDataSource sample in dtSearch\examples\NetStd.
Multithreaded indexing is 64-bit only.
The IndexJob setting AutoCommitIntervalMB does not apply to multithreaded index updates.
Topic |
Description |
The following tables list the members exposed by JobBase. | |
The properties of the JobBase class are listed here. |
Topic |
Description |
The following tables list the members exposed by IndexJob. | |
The properties of the IndexJob class are listed here. |
IndexJob Class |
Description |
Add documents to an existing index. If ActionCreate is not set, the index must already exist or the IndexJob will fail. | |
Remove obsolete information from the index. | |
Create a new index. If an index already exists in the specified directory, the index will be destroyed and replaced with a new, empty index. | |
Merge the indexes listed in IndexesToMerge into the index in IndexPath. | |
Check that each file in the index still exists on disk and remove from the index any files that no longer exist. | |
Remove the files listed in the text file identified by ToRemoveListName from the index. | |
Scan all index structures in the index to verify that the index is not damaged. | |
Number of megabytes to index before committing the index update. | |
Path to an index to use as a model when creating an index to ensure that the new index has options that are compatible with the other index. | |
DataSources to index for multithreaded indexing (one DataSource object must be provided for each thread). When using the multithreaded DataSource API, the indexer will index all documents returned from GetNextDoc even if they have not changed since the last time they were indexed, so to prevent redundant indexing, the indexing application should only return new or modified documents from the DataSource. | |
DataSource object to index. | |
A set of fields to be stored in the index for each document in a way that lets them be enumerated by WordListBuilder.ListFieldValues | |
Filters specifying documents not to index in the selected folders. | |
List of folders (or files) to index (add <+> after a folder name to include subfolders). | |
Filters specifying documents to index in the FoldersToIndex. | |
Full path of the folder where the index is located. | |
Indexes to merge into the target index, which is IndexPath. (ActionMerge must be true for the merge to occur.) For each index, provide the full path to the index. | |
Flags controlling the indexing of documents. | |
MaxMemToUseMB controls the size of the memory buffers that dtSearch can use to sort words during indexing. | |
If non-zero, the first doc id to assign to documents in this index. | |
Object to receive status update notifications during indexing. Can be used to provide a progress display and to provide an opportunity to cancel an index update. | |
A set of fields to be stored in the index for each document and returned as document properties in SearchResults. | |
Folder to use instead of the index folder for temporary files during indexing. | |
For multithreaded indexing, the number of indexing threads to use. | |
Name of file containing list of files to add to the index. | |
Name of file containing list of files to remove from the index. |
Copyright (c) 1998-2023 dtSearch Corp. All rights reserved.
|