From b75fde81853fe2a55d14eb3332d5fb74c819c9b9 Mon Sep 17 00:00:00 2001 From: Mahdi Bazrafshan Date: Sun, 26 Jul 2026 12:05:52 +0330 Subject: [PATCH] fix(models): add text field to ChunkMetadata for Qdrant storage Why: - Qdrant was storing only metadata, not chunk text - Queries returned empty text in retrieved chunks - Scores were low (~0.25) because embeddings were on empty strings Changes: - Added 'text' field to ChunkMetadata model - Updated chunk_to_metadata() to copy text --- src/core/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/models.py b/src/core/models.py index 9d997ba..27ef230 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -21,7 +21,6 @@ class Chunk(BaseModel): Strategy-specific fields (parent_id, enriched_content) are nullable when not applicable to the strategy that produced the chunk. """ - document_name: str chunk_id: str strategy_name: StrategyName @@ -35,11 +34,11 @@ class Chunk(BaseModel): class ChunkMetadata(BaseModel): """Payload stored alongside every chunk vector in Qdrant.""" - document_name: str chunk_id: str strategy_name: StrategyName chunk_index: int + text: str token_count: int character_count: int parent_id: Optional[str] = None @@ -52,6 +51,7 @@ def chunk_to_metadata(chunk: Chunk) -> ChunkMetadata: chunk_id=chunk.chunk_id, strategy_name=chunk.strategy_name, chunk_index=chunk.chunk_index, + text=chunk.text, token_count=chunk.token_count, character_count=chunk.character_count, parent_id=chunk.parent_id, @@ -92,4 +92,4 @@ class PaginatedResponse(BaseModel): items: list = Field(default_factory=list) total: int = 0 offset: int = 0 - limit: int = 50 \ No newline at end of file + limit: int = 50