Table of Contents

Class SyncedFileSystemDirectoryFactory

Namespace
Examine.Lucene.Directories
Assembly
Examine.Lucene.dll

A directory factory that replicates the index from main storage on initialization to another directory, then creates a Lucene Directory based on that replicated index.

public class SyncedFileSystemDirectoryFactory : FileSystemDirectoryFactory, IDirectoryFactory, ITaxonomyDirectoryFactory
Inheritance
SyncedFileSystemDirectoryFactory
Implements
Inherited Members

Remarks

A replication thread is spawned to then replicate the local index back to the main storage location. By default, Examine configures the local directory to be the %temp% folder. This also checks if the main/local storage indexes are healthy and syncs/removes accordingly.

Constructors

SyncedFileSystemDirectoryFactory(DirectoryInfo, DirectoryInfo, ILockFactory, ILoggerFactory, IOptionsMonitor<LuceneDirectoryIndexOptions>)

Initializes a new instance of the SyncedFileSystemDirectoryFactory class.

public SyncedFileSystemDirectoryFactory(DirectoryInfo localDir, DirectoryInfo mainDir, ILockFactory lockFactory, ILoggerFactory loggerFactory, IOptionsMonitor<LuceneDirectoryIndexOptions> indexOptions)

Parameters

localDir DirectoryInfo

The local directory where the index will be replicated.

mainDir DirectoryInfo

The main directory where the index is stored.

lockFactory ILockFactory

The lock factory used for managing index locks.

loggerFactory ILoggerFactory

The logger factory used for creating loggers.

indexOptions IOptionsMonitor<LuceneDirectoryIndexOptions>

The options monitor for Lucene directory index options.

SyncedFileSystemDirectoryFactory(DirectoryInfo, DirectoryInfo, ILockFactory, ILoggerFactory, IOptionsMonitor<LuceneDirectoryIndexOptions>, bool)

Initializes a new instance of the SyncedFileSystemDirectoryFactory class.

public SyncedFileSystemDirectoryFactory(DirectoryInfo localDir, DirectoryInfo mainDir, ILockFactory lockFactory, ILoggerFactory loggerFactory, IOptionsMonitor<LuceneDirectoryIndexOptions> indexOptions, bool tryFixMainIndexIfCorrupt)

Parameters

localDir DirectoryInfo

The local directory where the index will be replicated.

mainDir DirectoryInfo

The main directory where the index is stored.

lockFactory ILockFactory

The lock factory used for managing index locks.

loggerFactory ILoggerFactory

The logger factory used for creating loggers.

indexOptions IOptionsMonitor<LuceneDirectoryIndexOptions>

The options monitor for Lucene directory index options.

tryFixMainIndexIfCorrupt bool

Indicates whether to attempt fixing the main index if it is corrupt.

Methods

CreateDirectory(LuceneIndex, bool)

Creates the directory instance

public override Directory CreateDirectory(LuceneIndex luceneIndex, bool forceUnlock)

Parameters

luceneIndex LuceneIndex
forceUnlock bool

If true, will force unlock the directory when created

Returns

Directory

Remarks

Any subsequent calls for the same index will return the same directory instance

CreateTaxonomyDirectory(LuceneIndex, bool)

Creates the taxonomy directory for the index.

public override Directory? CreateTaxonomyDirectory(LuceneIndex luceneIndex, bool forceUnlock)

Parameters

luceneIndex LuceneIndex
forceUnlock bool

Returns

Directory

Remarks

Unlike the base FileSystemDirectoryFactory (which writes directly to the configured base/main storage), the synced factory returns a directory backed by the local storage so the taxonomy index is written locally and then replicated to main storage on schedule, just like the main search index. Writing the taxonomy directly to main storage would defeat the purpose of the synced directory. The main taxonomy directory (the replication destination) is created separately via base.CreateTaxonomyDirectory inside TryCreateDirectory(LuceneIndex, bool, out Directory).