pub struct MessageFtsIndex { /* private fields */ }Expand description
FTS5-backed full-text index of chat-message bodies. Cheap to clone (Arc
inside). Stores only the tokenized inverted index + metadata; never retrievable
message text.
Implementations§
Source§impl MessageFtsIndex
impl MessageFtsIndex
Sourcepub fn open(path: PathBuf) -> Result<Self>
pub fn open(path: PathBuf) -> Result<Self>
Open (or create) the FTS index at path. A plain rusqlite connection —
FTS5 ships with the bundled SQLite amalgamation, so no extension load is
needed (unlike sqlite-vec’s open_vec_connection). The default db path
(~/.ryu/message-fts.db) is resolved Core-side by the search_host shim.
Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Open an in-memory FTS index. Used by tests (this crate’s and Core’s).
Sourcepub async fn index_message(
&self,
message_id: &str,
conversation_id: &str,
role: &str,
text: &str,
created_at: i64,
) -> Result<()>
pub async fn index_message( &self, message_id: &str, conversation_id: &str, role: &str, text: &str, created_at: i64, ) -> Result<()>
Index a single message’s body for full-text search. Idempotent on
message_id: a message already present is a no-op (append-only content is
immutable, so there is nothing to update). Empty/whitespace bodies are
skipped.
Sourcepub async fn indexed_ids(&self) -> Result<HashSet<String>>
pub async fn indexed_ids(&self) -> Result<HashSet<String>>
The set of message ids already indexed (used to compute the backfill set).
Sourcepub async fn search(
&self,
query: &str,
limit: usize,
conversation_ids: Option<&[String]>,
) -> Result<Vec<MessageFtsHit>>
pub async fn search( &self, query: &str, limit: usize, conversation_ids: Option<&[String]>, ) -> Result<Vec<MessageFtsHit>>
Full-text search over indexed message bodies. Sanitizes query into a safe
FTS5 MATCH expression (arbitrary chat text can otherwise trigger a syntax
error), runs a bm25()-ranked search, and optionally post-filters to a set
of conversation ids. Returns hits ordered most-relevant-first. An
empty/unusable query yields no hits (never an error).
Trait Implementations§
Source§impl Clone for MessageFtsIndex
impl Clone for MessageFtsIndex
Source§fn clone(&self) -> MessageFtsIndex
fn clone(&self) -> MessageFtsIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more