feat(search): fuzzy/typo tolerance fallback (pg_trgm word_similarity)
CI / backend (pull_request) Successful in 50s
CI / frontend (pull_request) Successful in 14s
Security / secrets (pull_request) Successful in 5s
Security / dependencies (pull_request) Successful in 54s

Slice 4 of search-core: when an exact free-text search returns zero results, fall
back to pg_trgm word_similarity on the subject (explicit 0.3 threshold — pg_trgm's
default 0.6 misses real typos like 'recieved'->'received' ~0.39). Fallback-only, so
it never dilutes good exact matches; fuzzy hits get no ts_headline. Migration enables
the pg_trgm extension (CREATE EXTENSION IF NOT EXISTS — idempotent).

Also relocates the EmailSummaryDto.MatchHighlight note to an XML doc: a comment inside
the record's parameter list was tripping dotnet-format's whitespace check on every
commit (mutating format wouldn't fix it) — moving it out clears that drift for good.

Verified end-to-end vs a live Postgres via throwaway test (removed): typo 'recieved'
fuzzy-matched a subject with 'received'. Build + all 40 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
cesnimda
2026-07-01 22:41:42 +02:00
parent 9bbab5d32a
commit c3f53eb470
6 changed files with 813 additions and 21 deletions
@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace InboxIntel.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class EnablePgTrgm : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("Npgsql:PostgresExtension:pg_trgm", ",,");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.OldAnnotation("Npgsql:PostgresExtension:pg_trgm", ",,");
}
}
}