Table of Contents

Method ReadNearestCandidatesAsync

Namespace
MailFathom.Application.Emails.Search
Assembly
MailFathom.Application.dll

ReadNearestCandidatesAsync(MailboxEmailSelection, RegisteredEmbeddingProfile, EmbeddingVector, int, CancellationToken)

Reads the emails whose nearest passage sits closest to a query vector, among those the filters select.

Task<SemanticEmailRankings> ReadNearestCandidatesAsync(MailboxEmailSelection selection, RegisteredEmbeddingProfile profile, EmbeddingVector queryVector, int limit, CancellationToken cancellationToken)

Parameters

selection MailboxEmailSelection

Which emails are eligible before any distance is measured.

profile RegisteredEmbeddingProfile

The vector space both the stored vectors and the query vector belong to.

queryVector EmbeddingVector

Where the query itself lands in that space.

limit int

The greatest number of candidates to return, at least one.

cancellationToken CancellationToken

Propagates caller cancellation.

Returns

Task<SemanticEmailRankings>

Two rankings of at most limit candidates each, nearest first, empty when no eligible message is embedded.

Remarks

A message appears once per ranking however many of its passages are near, scored by its nearest one. Ranking passages would let one long message fill a window with its own paragraphs while a shorter message that answers the query better never appears.

Two rankings out of one eligible set rather than one, because ADR 0030 separates a message placed by something a person wrote from one placed by a machine's account of a picture, and requires the separation to be made where the passages are still distinguishable. By the time fusion sees a ranking, a place in it is just a place; a single ranking labelled afterwards would let a description decide where a message sits while the result claimed a body placed it.

The order within each is deterministic, on the same terms the lexical ranking is: distance ties are broken by the newest-first timeline order, which is total. A message with no vector under this profile is absent rather than distant — mail that synchronization has stored and generation has not yet reached is not near anything.

Exceptions

ArgumentNullException

Thrown when any reference argument is null.

ArgumentOutOfRangeException

Thrown when limit is below one.