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<IReadOnlyList<RankedEmailCandidate>> ReadNearestCandidatesAsync(MailboxEmailSelection selection, RegisteredEmbeddingProfile profile, EmbeddingVector queryVector, int limit, CancellationToken cancellationToken)
Parameters
selectionMailboxEmailSelectionWhich emails are eligible before any distance is measured.
profileRegisteredEmbeddingProfileThe vector space both the stored vectors and the query vector belong to.
queryVectorEmbeddingVectorWhere the query itself lands in that space.
limitintThe greatest number of candidates to return, at least one.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task<IReadOnlyList<RankedEmailCandidate>>
At most
limitcandidates, nearest first, empty when no eligible message is embedded.
Remarks
A message appears once 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.
The order 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
limitis below one.