Skip to content

Use HybridSearch as the default UI search with a Vector/Hybrid toggle #3

Description

@netclectic

Summary

The UI search endpoint /api/memory/search currently uses SearchWithMetadataEmbedding, which fails to return results for short keyword queries (e.g., "race condition", "phobos"). The root cause and fix are documented in ADR docs/adr/2026-02-14-hybrid-search-rrf.md: cosine-similarity compression makes the default 0.7 threshold eliminate genuinely relevant content, while HybridSearch (vector + PostgreSQL FTS + Reciprocal Rank Fusion) resolves it — it's already the default in the MCP SearchMemories tool but was never wired into the web UI.

Changes

Backend (src/Memorizer/Controllers/MemoryController.cs)

  • SearchMemories (GET /api/memory/search) gains a [FromQuery] string? method = "hybrid" parameter.
  • hybrid (default) → _storage.HybridSearch(...); vector → existing SearchWithMetadataEmbedding. No storage-layer changes needed — both methods already exist on IStorage with identical signatures.

Frontend (src/Memorizer/Views/Home/Index.cshtml)

  • Add a Hybrid / Vector mode toggle to the search bar (Hybrid is the default).
  • Hybrid mode: placeholder "Search memories...", button "Search", hide the "Min similarity (0-1)" field (a no-op for HybridSearch per the ADR).
  • Vector mode: show the min-similarity field and the "Vector Search" button.
  • Rename runVectorSearch()runSearch() passing method=. Relabel the results header.
  • The sidebar search (/memories?q=...) routes through the same code path and benefits automatically.

Notes

  • No dependencies.
  • minSimilarity is accepted but not applied by HybridSearch (by design); the parameter is retained for API compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestuiWeb UI changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions