b5b03bfd78
Implements NextcloudClientProtocol for multi-document type search following user requirement that document types are not 1:1 with apps (e.g., Notes app specializes in markdown, while Files/WebDAV handles multiple file types). Key Changes: - NextcloudClientProtocol: Generic protocol with app-specific client properties - get_indexed_doc_types(): Query Qdrant for actually-indexed document types - Document dispatch: All algorithms check Qdrant before attempting access - Cross-type deduplication: Use (doc_id, doc_type) tuples in hybrid RRF Search Algorithm Updates: - Semantic: Added _verify_document_access() with dispatch to appropriate client - Deduplication by (doc_id, doc_type) tuple - Only "note" verification implemented, others return None with info log - Keyword: Added _fetch_documents() dispatch method - Queries Qdrant for available types before fetching - Supports cross-app search when doc_type=None - Fuzzy: Same pattern as keyword search - Hybrid: Already uses (doc_id, doc_type) for deduplication (no changes needed) Future-Proof Design: - File/calendar verification stubs in place - Clear logging when unsupported types found - Easy to extend when processor indexes new document types Currently Supported: - "note" documents fully implemented and tested - Other types gracefully handled (logged but skipped) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Search algorithms module for unified multi-algorithm search.
|
|
|
|
This module provides a unified interface for different search algorithms:
|
|
- Semantic search (vector similarity)
|
|
- Keyword search (token-based matching)
|
|
- Fuzzy search (character overlap)
|
|
- Hybrid search (RRF fusion of multiple algorithms)
|
|
|
|
All algorithms share the same interface and can be used interchangeably by both
|
|
MCP tools and the visualization pane.
|
|
"""
|
|
|
|
from nextcloud_mcp_server.search.algorithms import (
|
|
NextcloudClientProtocol,
|
|
SearchAlgorithm,
|
|
SearchResult,
|
|
get_indexed_doc_types,
|
|
)
|
|
from nextcloud_mcp_server.search.fuzzy import FuzzySearchAlgorithm
|
|
from nextcloud_mcp_server.search.hybrid import HybridSearchAlgorithm
|
|
from nextcloud_mcp_server.search.keyword import KeywordSearchAlgorithm
|
|
from nextcloud_mcp_server.search.semantic import SemanticSearchAlgorithm
|
|
|
|
__all__ = [
|
|
"NextcloudClientProtocol",
|
|
"SearchAlgorithm",
|
|
"SearchResult",
|
|
"get_indexed_doc_types",
|
|
"SemanticSearchAlgorithm",
|
|
"KeywordSearchAlgorithm",
|
|
"FuzzySearchAlgorithm",
|
|
"HybridSearchAlgorithm",
|
|
]
|