Section navigation

Public classSealed IndexWriterConfig

Namespace
Rowles.LeanCorpus.Index.Indexer
Assembly
Rowles.LeanCorpus.dll

Configuration for the IndexWriter.

public sealed class IndexWriterConfig
Inheritance
IndexWriterConfig

Public property AnalyserInternCacheSize

Maximum number of entries in the StandardAnalyser token intern cache. Larger caches reduce per-token string allocation for repeated terms. Default: 4096.

Public property BKDMaxLeafSize

Maximum number of point values in a BKD tree leaf node. Smaller leaves give faster range queries at the cost of larger index files. Default: 512.

Public property BuildHnswOnFlush

Build an HNSW graph for every vector field at flush time. Disable to fall back to flat brute-force scan (useful for tiny indices where the build overhead outweighs benefit). Default: true.

Public property CharFilters

Character-level filters applied to text before tokenisation. Runs in order before the analyser. Default: empty (no char filters).

Public property CodecCatalog

Gets or sets the immutable codec catalogue used when opening existing segments.

Public property CompatibilityMode

Compatibility guardrail applied when opening an existing index. Defaults to strict mode.

Public property CompressionPolicy

Compression algorithm for stored fields. Default: Deflate. Options: None, Deflate, Brotli, and any registered optional codec.

Public property DefaultAnalyser

Default analyser used for fields without a specific mapping.

Public property DeletionPolicy

Deletion policy applied after each commit. Default: keep latest only.

Public property DurableCommits

When true (default), Commit() flushes file contents and directory metadata to disk via fsync before and after the segments_N rename, guaranteeing the commit survives a power loss. If the final directory fsync fails after the atomic rename, the commit may already be visible but its durability is unconfirmed; Commit() throws and the writer must be disposed and reopened. Disable only for write-heavy benchmarks where durability is not required.

Public property FieldAnalysers

Per-field analyser overrides. Key is the field name.

Public property HnswBuildConfig

HNSW build configuration applied to every vector field. See HnswBuildConfig.

Public property HnswSeed

Optional deterministic seed for HNSW graph construction. When null, a random seed is generated per segment and persisted into the .hnsw file. Set explicitly for reproducible builds.

Public property IndexSort

Optional index-time sort order. When set, documents within each segment are physically reordered at flush time. Default: null (insertion order).

Public property MaxBufferedDocs

Maximum number of buffered documents before an automatic flush.

Public property MaxConcurrentFlushes

Maximum number of segment flushes allowed to execute concurrently.

Public property MaxConcurrentMerges

Maximum number of background merges allowed to run concurrently.

Public property MaxPendingMergeBytes

Pending merge bytes that trigger producer backpressure. Zero disables the byte limit.

Public property MaxQueuedBytes

Maximum estimated bytes retained by queued asynchronous documents.

Public property MaxQueuedDocs

Maximum number of documents that can be queued for indexing before AddDocument blocks. Provides backpressure to prevent unbounded memory growth. Set to 0 to disable (not recommended). Default: 2 × MaxBufferedDocs.

Public property MaxTokensPerDocument

Maximum number of tokens allowed per text field per document. 0 means unlimited (no budget enforcement). Default: 0.

Public property MergePolicy

The merge policy used to select segments for merging. Defaults to TieredMergePolicy with the configured MergeThreshold. Set to Instance to disable automatic merging.

Public property MergeThreshold

Segment count threshold that triggers a tiered merge. When the number of segments at a given size tier reaches this value, the smallest are merged. Default: 10. When MergePolicy is set to a non-default value, this property is ignored.

Public property MergeThrottleSegments

Maximum number of unmerged segments before AddDocument schedules a background merge and blocks until it completes. Provides backpressure to prevent unbounded segment accumulation. Default: 0 (disabled).

Public property Metrics

Metrics collector for flush, merge, and commit latency tracking. Default: NullMetricsCollector (no-op).

Public property NormaliseVectors

Whether vector fields should be normalised (L2) at index time. When true, dot product equals cosine similarity, enabling cheaper search. Default: true.

Public property PostingsSkipInterval

Skip interval for postings lists. Every N-th doc ID gets a skip pointer for O(log N) advance. Must be consistent between write and merge paths. Default: 128.

Public property RamBufferSizeMB

RAM buffer size in megabytes before an automatic flush.

Public property RamPerThreadHardLimitMB

Hard memory limit for one DWPT before it must be flushed.

Public property Schema

Optional schema defining per-field types and validation rules. When null (default), documents are accepted without schema validation.

Public property Similarity

Scoring model used by IndexSearcher. Default: BM25.

Public property SoftDeleteRetentionSeconds

Minimum number of seconds to retain soft-deleted documents before they are eligible for physical reclamation during a merge. Only used when SoftDeletesEnabled is true. Default: 86400 (24 hours).

Public property SoftDeletesEnabled

When true, soft-deleted documents are retained on disk until SoftDeleteRetentionSeconds elapses. The soft-delete timestamp is written alongside the live-docs bitmap in the .del file. Default: false.

Public property StopWords

Custom stop words for the default StandardAnalyser. When null, English (the classic 33-word English list) is used. Set to EnglishExtended for more aggressive filtering, or pass an empty list to disable stop word removal entirely.

Public property StorePayloads

Whether to store per-position payloads in the postings.

Public property StoreTermVectors

Whether to store term vectors for text fields.

Public property StoredFieldBlockSize

Number of documents per stored field block. Larger blocks compress better but increase random-access cost. Default: 16.

Public property TokenBudgetPolicy

Action taken when a document exceeds MaxTokensPerDocument. Default: Truncate.

Public property TrackSequenceNumbers

When true, each document is assigned a monotonically-increasing sequence number and the per-segment sequence number range is persisted in segment metadata. Default: false (off for backward compatibility).

Public property UseCompoundFile

Whether to store immutable segment codec files in one memory-mapped .cfs file. Deletion and segment-statistics files remain separate so they can be replaced without rewriting the compound file. Defaults to false for compatibility.

Public property VectorQuantisation

Quantisation strategy for vector fields. None (default) stores raw float32 vectors. Int8 gives ~4× storage reduction with minimal recall loss. BBQ gives ~32× reduction at some recall cost. Default: None.