Skip to main content

khive_storage/
text.rs

1//! Full-text search capability (ADR-024).
2
3use async_trait::async_trait;
4use uuid::Uuid;
5
6use crate::types::{
7    BatchWriteSummary, IndexRebuildScope, StorageResult, TextDocument, TextFilter, TextIndexStats,
8    TextSearchHit, TextSearchRequest,
9};
10
11#[async_trait]
12pub trait TextSearch: Send + Sync + 'static {
13    async fn upsert_document(&self, document: TextDocument) -> StorageResult<()>;
14    async fn upsert_documents(
15        &self,
16        documents: Vec<TextDocument>,
17    ) -> StorageResult<BatchWriteSummary>;
18    async fn delete_document(&self, namespace: &str, subject_id: Uuid) -> StorageResult<bool>;
19    async fn get_document(
20        &self,
21        namespace: &str,
22        subject_id: Uuid,
23    ) -> StorageResult<Option<TextDocument>>;
24    async fn search(&self, request: TextSearchRequest) -> StorageResult<Vec<TextSearchHit>>;
25    async fn count(&self, filter: TextFilter) -> StorageResult<u64>;
26    async fn stats(&self) -> StorageResult<TextIndexStats>;
27    async fn rebuild(&self, scope: IndexRebuildScope) -> StorageResult<TextIndexStats>;
28}