Class SemanticEmailSearch
- Namespace
- MailFathom.Application.Emails.Search
- Assembly
- MailFathom.Application.dll
Ranks mail by meaning, or reports why this search cannot be answered that way.
public sealed class SemanticEmailSearch
- Inheritance
-
SemanticEmailSearch
- Inherited Members
Remarks
Everything that has to hold before a distance means anything is established here and in one place: that this instance has activated a profile, that it has an embedding provider at all, that the provider it would call reaches the same vector space that profile's stored vectors were written under, and that the provider is currently answering. A caller receives either a ranking or nothing, and never a ranking computed against a space the stored vectors do not belong to.
None of those is a failure. An instance with no active profile serves lexical search and is a supported deployment; an instance whose provider is briefly unreachable serves lexical search for the length of the outage. Raising would turn a mailbox search into an error because an external service was busy, which is a worse answer than the results the local index can already give. What every caller does receive is the SemanticSearchCapability separating those cases, so a degraded instance is legible rather than merely quieter.
A provider known to be failing is not called again by every search that arrives while it refuses. The health state is what the embedding workers' own calls established, so consulting it costs nothing and spends nothing, and a refused credential stops buying one rejected request per query. What it is not is a latch: after MailFathom.Application.Emails.Search.SemanticEmailSearch.ProviderRecheckInterval without a fresh observation, one search is allowed through to find out, so recovery is automatic and needs no restart even on an instance whose mail is fully embedded and whose workers are therefore calling nobody.
The query text is the most revealing value any search carries, so nothing here records it: no failure this type raises repeats it, and the vector it produces is held for the length of one call and published to nobody.
Constructors
- SemanticEmailSearch(IActiveEmbeddingProfileReader, IEmailVectorSearchIndexReader, IAiProviderHealthReader, TimeProvider, ITextEmbeddingGenerator?)
Initializes semantic retrieval over whatever this deployment configured.
Methods
- FindNearestCandidatesAsync(MailboxEmailSelection, EmailSearchQueryText, int, CancellationToken)
Ranks the eligible mail by how near it sits to what the query means.
- ReadCapabilityAsync(CancellationToken)
Reads what semantic retrieval can do for this instance, without calling a provider.