Search Unit Configuration

Advantage CSP: Programmatic Index Management with SearchUnit

Advantage CSP: Programmatic Index Management with SearchUnit

Advantage CSP includes SearchUnit, offering a comprehensive index management tool for handling various aspects of the index, including document importation from diverse sources. While the graphical Index Management tool is intuitive for most tasks, there are instances when direct programmatic interaction with the index is preferable. This might include incremental addition or removal of documents, among other operations.
 
Programmatically Importing Sources

Importing a source—whether a website, file system folder, database, or DataSet—entails scanning for and indexing all eligible documents based on specified criteria. Programmatic reimportation triggers a rescan of the source to capture updates or, if necessary, reindexes everything.

C# Example for Various Imports:

Website Import:

Website Import

DocumentIndex documentIndex = new DocumentIndex(configuration);
documentIndex.ImportWebsite(startURL);
// Alternatively:
documentIndex.Import(new WebsiteBasedIndexableSourceRecord(startURL, pathsToIgnore, pathsToInclude));

File System Folder Import:

File System Folder Import

documentIndex.ImportFileSystemFolder(localFolderPath, virtualPath, targetMatchList, ignoreMatchList, recurseSubFolders);

Database Import:

Database Import

documentIndex.ImportDatabase(sourceType, connectionString, sqlQuery, uniqueColumnName, resultUrlFormat);

Custom DataSet Import (from an assembly:

Custom DataSet Import (from an assembly

documentIndex.ImportCustomDataSet(assemblyFilePath, fullClassName, uniqueColumnName, resultUrlFormat);

Always close the documentIndex after operations to ensure proper resource management.


Adding Individual Documents

For incremental updates to the index as new documents become available, you can add documents one at a time.

 Note: The completion time for Add Document varies. It's recommended not to use this method in web applications where immediate page response is required.

 
Asynchronous Document Addition

To avoid delays in web applications, documents can be queued for background indexing using the AsynchronousQueue class.

C# Example for Asynchronous Addition:

Example for Adding a Document:

DocumentIndexdocumentIndex=newDocumentIndex(configuration);documentIndex.RemoveDocument(new Document(uriToMatchExactly, Configuration));


    documentIndex.AddDocument(new Document("http://some/URL/document", configuration));
} finally {
    documentIndex.Close();
}
 For database-originated documents, recreate the URI based on the IndexableSource ID and unique field.
 
Adding Data as Strings

For scenarios where data doesn't reside in traditional documents—like indexing extra descriptions or database content—use the PreloadedDocument class.

C# Example for PreloadedDocument:

PreloadedDocument

documentIndex.AddDocument(new PreloadedDocument(uri, title, text, summary, null, null, null, customData, configuration));

To remove a PreloadedDocument, use the RemoveDocument method with the same URI used during creation.

By leveraging these programmatic capabilities, users of Advantage CSP can enhance their SearchUnit index management, tailoring it to their specific requirements for efficient and dynamic content indexing and updating.
Back to Top Button