fix: Update models and viz to use int-only doc_id
- algorithms.py: Revert SearchResult.id to int (all docs use int IDs now) - semantic.py: Revert SemanticSearchResult.id to int, remove Union import - viz_routes.py: Remove str() conversion when querying doc_id from Qdrant - viz_routes.py: Convert doc_id from query param to int in chunk context Fixes vector visualization which was collapsing all chunks to a single point because Qdrant queries were failing to match doc_id (string vs int).
This commit is contained in:
@@ -235,7 +235,7 @@ async def vector_visualization_search(request: Request) -> JSONResponse:
|
|||||||
must_conditions = [
|
must_conditions = [
|
||||||
FieldCondition(
|
FieldCondition(
|
||||||
key="doc_id",
|
key="doc_id",
|
||||||
match=MatchValue(value=str(result.id)),
|
match=MatchValue(value=result.id),
|
||||||
),
|
),
|
||||||
FieldCondition(
|
FieldCondition(
|
||||||
key="user_id",
|
key="user_id",
|
||||||
@@ -524,6 +524,8 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
|
|||||||
|
|
||||||
start = int(start_str)
|
start = int(start_str)
|
||||||
end = int(end_str)
|
end = int(end_str)
|
||||||
|
# Convert doc_id to int (all document types use int IDs)
|
||||||
|
doc_id_int = int(doc_id)
|
||||||
|
|
||||||
# Get authenticated Nextcloud client
|
# Get authenticated Nextcloud client
|
||||||
from nextcloud_mcp_server.auth.userinfo_routes import (
|
from nextcloud_mcp_server.auth.userinfo_routes import (
|
||||||
@@ -536,7 +538,7 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
|
|||||||
chunk_context = await get_chunk_with_context(
|
chunk_context = await get_chunk_with_context(
|
||||||
nc_client=nc_client,
|
nc_client=nc_client,
|
||||||
user_id=request.user.display_name, # User ID from auth
|
user_id=request.user.display_name, # User ID from auth
|
||||||
doc_id=doc_id,
|
doc_id=doc_id_int,
|
||||||
doc_type=doc_type,
|
doc_type=doc_type,
|
||||||
chunk_start=start,
|
chunk_start=start,
|
||||||
chunk_end=end,
|
chunk_end=end,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from .base import BaseResponse
|
|||||||
class SemanticSearchResult(BaseModel):
|
class SemanticSearchResult(BaseModel):
|
||||||
"""Model for semantic search results with additional metadata."""
|
"""Model for semantic search results with additional metadata."""
|
||||||
|
|
||||||
id: int = Field(description="Document ID")
|
id: int = Field(description="Document ID (int for all document types)")
|
||||||
doc_type: str = Field(
|
doc_type: str = Field(
|
||||||
description="Document type (note, calendar_event, deck_card, etc.)"
|
description="Document type (note, calendar_event, deck_card, etc.)"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class SearchResult:
|
|||||||
"""A single search result with metadata and score.
|
"""A single search result with metadata and score.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
id: Document ID
|
id: Document ID (int for all document types)
|
||||||
doc_type: Document type (note, file, calendar, contact, etc.)
|
doc_type: Document type (note, file, calendar, contact, etc.)
|
||||||
title: Document title
|
title: Document title
|
||||||
excerpt: Content excerpt showing match context
|
excerpt: Content excerpt showing match context
|
||||||
|
|||||||
Reference in New Issue
Block a user