You can initialize the SearchEngine using three different approaches depending on your requirements for speed versus accuracy:
- Default Configuration: Recommended for most use cases. It uses multi-size n-grams ([2, 3]) and enables full coverage (exact, LD1 fuzzy, prefix/suffix, join/split, and LCS) to balance speed and accuracy.
- Minimal Configuration: Optimized for maximum speed. It uses a single n-gram size ([3]) and disables coverage.
- Custom Configuration: Allows full control over n-gram sizes, padding, coverage settings, text normalization, tokenization, and word matching parameters.
When using custom configuration, you can also define fieldWeights to adjust the importance of different fields during search.
// Default Configuration (Recommended)
var engine = SearchEngine.CreateDefault();
// Minimal Configuration (Speed Priority)
var engine = SearchEngine.CreateMinimal();
// Custom Configuration
var engine = new SearchEngine(
indexSizes: new[] { 2, 3 }, // Character n-gram sizes
startPadSize: 2, // Pad start of words
stopPadSize: 0, // Pad end of words
enableCoverage: true, // Enable lexical matching
textNormalizer: TextNormalizer.CreateDefault(),
tokenizerSetup: TokenizerSetup.CreateDefault(),
coverageSetup: CoverageSetup.CreateDefault(),
wordMatcherSetup: new WordMatcherSetup
{
SupportLD1 = true, // Enable fuzzy matching
SupportAffix = true, // Enable prefix/suffix
MinimumWordSizeExact = 2,
MaximumWordSizeExact = 50,
MinimumWordSizeLD1 = 4,
MaximumWordSizeLD1 = 20
},
fieldWeights: new[] { 1.0f, 2.0f } // Per-field weights
);