pub struct SqliteStore { /* private fields */ }Expand description
VectorStore persisted in one SQLite file, with cosine and BM25 search.
use std::sync::Arc;
use graphrt_rag::{HashEmbedder, KnowledgeBase, SqliteStore};
let store = SqliteStore::open("knowledge.db")?;
let kb = KnowledgeBase::new().with_store_dataset("faq", Arc::new(store), Arc::new(HashEmbedder::new(256)), None);Implementations§
Source§impl SqliteStore
impl SqliteStore
Sourcepub fn open(path: impl Into<PathBuf>) -> Result<Self, RagError>
pub fn open(path: impl Into<PathBuf>) -> Result<Self, RagError>
Open (or create) the database at path and load its chunks.
@throws RagError::Io when the file cannot be opened, RagError::Decode
when it was written by an unsupported schema version or holds corrupt rows.
Trait Implementations§
Source§impl Debug for SqliteStore
impl Debug for SqliteStore
Source§impl VectorStore for SqliteStore
impl VectorStore for SqliteStore
Source§fn upsert(
&self,
chunks: Vec<StoredChunk>,
) -> BoxFuture<'_, Result<(), RagError>>
fn upsert( &self, chunks: Vec<StoredChunk>, ) -> BoxFuture<'_, Result<(), RagError>>
Insert or replace chunks (by
id).Source§fn delete_document<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_document<'a>( &'a self, dataset_id: &'a str, document_id: &'a str, ) -> BoxFuture<'a, Result<usize, RagError>>
Remove every chunk of a document. Returns the number removed when known.
Source§fn delete_dataset<'a>(
&'a self,
dataset_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_dataset<'a>( &'a self, dataset_id: &'a str, ) -> BoxFuture<'a, Result<usize, RagError>>
Remove every chunk of a dataset.
Source§fn document_chunks<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<Vec<StoredChunk>, RagError>>
fn document_chunks<'a>( &'a self, dataset_id: &'a str, document_id: &'a str, ) -> BoxFuture<'a, Result<Vec<StoredChunk>, RagError>>
Every chunk of one document, vectors included. The ingestor uses this to
re-ingest a document without re-embedding unchanged chunks and to find the
chunks a new version no longer contains.
Source§fn delete_chunks<'a>(
&'a self,
dataset_id: &'a str,
ids: &'a [String],
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_chunks<'a>( &'a self, dataset_id: &'a str, ids: &'a [String], ) -> BoxFuture<'a, Result<usize, RagError>>
Remove chunks by id. Returns the number removed when known.
Source§fn search<'a>(
&'a self,
query: VectorQuery<'a>,
) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
fn search<'a>( &'a self, query: VectorQuery<'a>, ) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
Nearest neighbours by cosine similarity, best first.
Source§fn supports_keyword(&self) -> bool
fn supports_keyword(&self) -> bool
Whether
VectorStore::keyword_search is implemented.Source§fn keyword_search<'a>(
&'a self,
query: KeywordQuery<'a>,
) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
fn keyword_search<'a>( &'a self, query: KeywordQuery<'a>, ) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
Keyword (BM25) search, best first. Stores without a keyword index return nothing.
Source§fn contains_hash<'a>(
&'a self,
dataset_id: &'a str,
content_hash: &'a str,
) -> BoxFuture<'a, Result<bool, RagError>>
fn contains_hash<'a>( &'a self, dataset_id: &'a str, content_hash: &'a str, ) -> BoxFuture<'a, Result<bool, RagError>>
Whether a chunk with this content hash already exists in the dataset.
Stores that cannot answer cheaply return
false. The built-in crate::Ingestor
does not use this (it de-duplicates per document via VectorStore::document_chunks).Auto Trait Implementations§
impl !Freeze for SqliteStore
impl Forget for SqliteStore
impl Move for SqliteStore
impl RefUnwindSafe for SqliteStore
impl Send for SqliteStore
impl Sync for SqliteStore
impl Unpin for SqliteStore
impl UnsafeUnpin for SqliteStore
impl UnwindSafe for SqliteStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more