Coverage

Coverage is a collection of algorithms that detect exact and near-exact token matches in the query, lifting them to the top of the result list. It complements the core pattern recognition which always runs first.

How It Works

After pattern matching produces ranked candidates, coverage analyzes the top-K results (controlled by CoverageDepth) and scores each 0–65535 based on how much of the query the document covers. Results confirmed by coverage are promoted above pure pattern matches.

How Coverage Ranks

The score is the share of the query text the document covers, so 65535 means all of it. Among documents that cover the query equally, three small deductions decide the order:

DeductionAmountWhen
Word out of order
257 per word
An exactly matched word breaks the query's word order. Order is relative: the phrase in order anywhere in the text is in order
Not at the start
16
The document does not begin with the query's first word
Ends inside a word
8
The whole query was found as one string, but its last character is followed by more letters

When the whole query appears in the document as one string, it sets a floor under the score, by where that string starts:

Whole query foundScore at least
At the start of the document
65535
At the start of a word further in
65519
Inside a word
(q − 1) / q × 65535, where q is the query length

This is what makes search-as-you-type rank well. For knut h, the final h is too short to count as a word, but knut hamsun contains the whole query and scores 65527 (starts the document, ends inside a word), while knut faldbakken covers only knut and scores 43690.

Diacritic folding follows the TextNormalizer. In one-way mode (the default) a query is folded only against a document whose text folds, so blåbær fully matches blåbær but not blabar, while blabar fully matches both. In two-way mode both sides always fold, and the two spellings are the same query.

CoverageSetup

csharp
CoverageSetup cov = new CoverageSetup();

// Strict mode: only whole words
cov.CoverFuzzyWords = false;
cov.CoverPrefixSuffix = false;
cov.CoverWholeQuery = false;
cov.CoverJoinedWords = true;
cov.CoverWholeWords = true;
cov.MinWordSize = 3;

query.CoverageSetup = cov;

Detection Algorithms

PropertyDefaultDescription
CoverWholeQuery
true
Detect the whole search query as a single string, and let it set a floor under the score (see above)
CoverWholeWords
true
Detect individual whole words from the query
CoverFuzzyWords
true
Detect words with minor error tolerance
CoverJoinedWords
true
Detect words that are joined or split
CoverPrefixSuffix
true
Detect incomplete strings as prefix or suffix

Result Control

PropertyDefaultDescription
Truncate
true
Cut results at the truncation index
IncludePatternMatches
true
Include pure pattern matches
TruncationScore
65024
A result at or above this score is never cut
TruncateWordHitLimit
1
Minimum query words that must match
TruncateWordHitTolerance
0
Max difference in word hit count from best result

Common Patterns

Coverage should be kept enabled for nearly all use cases, including search-as-you-type. It is fast and improves result quality across multiple searchable fields.

Agent/tool usage (near-exact hits only):

csharp
CoverageSetup cov = new CoverageSetup();
cov.IncludePatternMatches = false;
query.CoverageSetup = cov;

Run coverage but keep all results:

csharp
CoverageSetup cov = new CoverageSetup();
cov.Truncate = false;
query.CoverageSetup = cov;

Deep coverage (evaluate all documents):

csharp
query.CoverageDepth = engine.Status.DocumentCount;

Constructors

csharp
CoverageSetup()

Default ctor.

Properties

NameTypeAccessDescription
IncludePatternMatches
bool
get/set
Gets or sets a value indicating whether pure pattern matches that are not detected by Coverage are included in the results. Set this to false if you only want near-exact matches returned. Should be used with Coverage enabled.
LevenshteinMaxWordSize
int
get/set
Longest word for Coverage to do edit distance calculation. This does not affect the fault tolerance of the pattern recognition search. Max value is 63.
MinWordSize
int
get/set
Smallest number of characters to hit for CoverageScoreEntry to give full word hits score.
TruncateWordHitLimit
int
get/set
The smallest number of words to hit for truncation of the search result list. The effective limit may be higher, since it is also determined by TruncateWordHitTolerance.
TruncateWordHitTolerance
int
get/set
Maximum difference in number of word hits to maxWordHits to truncate the result list. maxWordHits is calculated for entire result list. The truncation criteria is expressed by bool doTruncate = wordHits >= Max(TruncateWordHitLimit, maxWordHits - TruncateWordHitTolerance).
CoverWholeQuery
bool
get/set
Sets whether to detect the whole search query as a string. A document containing it gets a floor under its coverage score, by where the string starts: 65535 at the start of the document, 65519 at the start of a word further in, (q - 1) / q of the maximum inside a word; 8 less for the first two when it ends inside a word. This is what ranks a query being typed, such as "knut h", whose last word is too short to match as a word. A document containing the whole query is also never cut by truncation.
CoverWholeWords
bool
get/set
Sets whether to detect whole words from the string in the result list. This will look for multiple words.
CoverFuzzyWords
bool
get/set
Sets whether to detect words with an edit distance of 1.
CoverJoinedWords
bool
get/set
Sets whether to detect words that are either joined or split up. Both will be returned in the same query.
CoverPrefixSuffix
bool
get/set
Sets whether to detect incomplete strings as prefix or suffix of a bigger word.
Truncate
bool
get/set
If Truncate is enabled the list of result will be truncated at the point of TruncationIndex.
TruncationScore
UInt16
get/set
Always truncate at or above this score. Represents the 16-bit score of the truncation point in the search result (0..65535). Default 65024 is the 16-bit equivalent of the old byte default 254 (254 * 257).