diff --git a/nextcloud_mcp_server/search/context.py b/nextcloud_mcp_server/search/context.py index a3449b5c..f818e278 100644 --- a/nextcloud_mcp_server/search/context.py +++ b/nextcloud_mcp_server/search/context.py @@ -198,7 +198,7 @@ async def _get_deck_metadata_from_qdrant( async def get_chunk_bbox_and_page_from_qdrant( user_id: str, - doc_id: int | str, + doc_id: str, chunk_index: int | None, chunk_start: int, chunk_end: int, @@ -214,7 +214,11 @@ async def get_chunk_bbox_and_page_from_qdrant( Args: user_id: User ID who owns the document - doc_id: Document ID (int for file/note, str for some doc types) + doc_id: Document ID — always a string. Producers stringify their + native ID before writing to Qdrant so the keyword payload + index on ``doc_id`` matches every point regardless of source + doc_type. An ``int`` filter against the str-indexed payload + would silently match zero points. chunk_index: Zero-based chunk index, or None to use offset fallback chunk_start: Character offset where chunk starts (used when chunk_index is None) diff --git a/tests/unit/test_chunk_bbox_helper.py b/tests/unit/test_chunk_bbox_helper.py index af542353..f7abed91 100644 --- a/tests/unit/test_chunk_bbox_helper.py +++ b/tests/unit/test_chunk_bbox_helper.py @@ -58,7 +58,7 @@ class TestIndexedPath: with ctx: result = await get_chunk_bbox_and_page_from_qdrant( user_id="alice", - doc_id=42, + doc_id="42", chunk_index=3, chunk_start=0, chunk_end=100, @@ -84,7 +84,7 @@ class TestOffsetFallbackPath: with ctx: result = await get_chunk_bbox_and_page_from_qdrant( user_id="bob", - doc_id=99, + doc_id="99", chunk_index=None, chunk_start=500, chunk_end=600, @@ -105,7 +105,7 @@ class TestOffsetFallbackPath: with ctx, caplog.at_level("WARNING"): result = await get_chunk_bbox_and_page_from_qdrant( user_id="bob", - doc_id=99, + doc_id="99", chunk_index=None, chunk_start=0, chunk_end=100, @@ -124,7 +124,7 @@ class TestPayloadShape: with ctx: result = await get_chunk_bbox_and_page_from_qdrant( user_id="alice", - doc_id=1, + doc_id="1", chunk_index=0, chunk_start=0, chunk_end=10, @@ -143,7 +143,7 @@ class TestPayloadShape: with ctx: result = await get_chunk_bbox_and_page_from_qdrant( user_id="alice", - doc_id=42, + doc_id="42", chunk_index=3, chunk_start=0, chunk_end=100, @@ -157,7 +157,7 @@ class TestPayloadShape: with ctx: result = await get_chunk_bbox_and_page_from_qdrant( user_id="alice", - doc_id=42, + doc_id="42", chunk_index=3, chunk_start=0, chunk_end=100, @@ -171,7 +171,7 @@ class TestPayloadShape: with ctx: result = await get_chunk_bbox_and_page_from_qdrant( user_id="alice", - doc_id=42, + doc_id="42", chunk_index=3, chunk_start=0, chunk_end=100, @@ -188,7 +188,7 @@ class TestPayloadShape: with ctx: result = await get_chunk_bbox_and_page_from_qdrant( user_id="alice", - doc_id=42, + doc_id="42", chunk_index=3, chunk_start=0, chunk_end=100, @@ -205,7 +205,7 @@ class TestExceptionHandling: with ctx, caplog.at_level("WARNING"): result = await get_chunk_bbox_and_page_from_qdrant( user_id="alice", - doc_id=42, + doc_id="42", chunk_index=3, chunk_start=0, chunk_end=100,