Skip to content

[FIX] brain_search vec0 chunk results show placeholder excerpts instead of real content #192

Description

@four-bytes-robby

Bug

brain_search returns vec0 chunk results with useless placeholder excerpts like [vec0 chunk] distance=13.3280 instead of actual matched text content. Users get opaque UUIDs and meaningless distance numbers.

Root Cause

src/search/unified.tssearchVec0() (line ~301-341) queries ONLY the chunks_vec virtual table (chunk_id + distance), then maps a hardcoded placeholder string as the excerpt. It never JOINs the chunks table or does a second-step batch resolution to fetch actual chunks.content.

The fallback path searchChunksFallback (line ~348-424) correctly JOINs chunks + documents and returns real excerpts — but this path is only used when the vec0 extension isn't loaded (production uses vec0).

Fix

After the vec0 KNN query returns chunk_id list, add a batch SELECT id, content, symbol, chunk_type, start_line, end_line FROM chunks WHERE id IN (...) and populate excerpt with actual content (truncated to ~80 chars, matching the fallback path behavior). Also populate title with a meaningful label (symbol or doc:type#index) instead of vec0:<id>.

Expected Behavior

vec0 chunk results should show actual text excerpts, same as fallback path and FTS5 results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions