From f1610bbd2e307a601739b36efd16f959d46777ac Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Thu, 20 Nov 2025 11:33:12 +0100 Subject: [PATCH] fix: Reconstruct full content for notes to match indexed offsets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notes are indexed as "{title}\n\n{content}" in processor.py but were being retrieved as just content during chunk expansion, causing chunk_start_offset and chunk_end_offset to be misaligned. This fix reconstructs the full content structure when fetching notes for chunk expansion, ensuring the displayed chunks match the excerpts shown in search results. Fixes chunk/excerpt mismatch reported in vector visualization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- nextcloud_mcp_server/search/context.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nextcloud_mcp_server/search/context.py b/nextcloud_mcp_server/search/context.py index 43be81b..9f1b2d7 100644 --- a/nextcloud_mcp_server/search/context.py +++ b/nextcloud_mcp_server/search/context.py @@ -153,7 +153,11 @@ async def _fetch_document_text( if doc_type == "note": # Fetch note by ID note = await nc_client.notes.get_note(note_id=int(doc_id)) - return note.get("content", "") + # Reconstruct full content as indexed: title + "\n\n" + content + # This ensures chunk offsets align with indexed content structure + title = note.get("title", "") + content = note.get("content", "") + return f"{title}\n\n{content}" elif doc_type == "file": # Fetch file content via WebDAV try: