pub struct Store { /* private fields */ }Expand description
A persistent embedded vector database with lazy collection handles.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Opens or safely creates a database at path.
Sourcepub fn collection(&self, name: impl Into<String>) -> CollectionHandle
pub fn collection(&self, name: impl Into<String>) -> CollectionHandle
Returns a lazy handle for a named collection.
This method performs no repository write. A missing collection is
created by its first nonempty CollectionHandle::upsert.
Examples found in repository?
More examples
examples/quickstart.rs (line 6)
3fn main() -> git_vdb::Result<()> {
4 let temporary = tempfile::TempDir::new()?;
5 let db = open(temporary.path().join("vectors.git"))?;
6 let docs = db.collection("docs");
7 docs.upsert([
8 Point::new("east", [1.0, 0.0]),
9 Point::new("north", [0.0, 1.0]),
10 ])?;
11 let hits = docs.search([0.9, 0.1], 1)?;
12 assert_eq!(hits[0].id.to_string(), "east");
13 Ok(())
14}examples/filtering.rs (line 6)
4fn main() -> git_vdb::Result<()> {
5 let temporary = tempfile::TempDir::new()?;
6 let docs = open(temporary.path().join("vectors.git"))?.collection("docs");
7 docs.upsert([
8 Point::new("guide", [1.0, 0.0]).with_metadata(json!({"kind": "docs"}))?,
9 Point::new("code", [0.9, 0.1]).with_metadata(json!({"kind": "source"}))?,
10 ])?;
11 let result = docs.advanced()?.query(
12 Query::new([1.0, 0.0], 5)
13 .with_filter(Filter::must([Condition::matches("kind", "docs")]))
14 .with_payload(),
15 )?;
16 assert_eq!(result.points[0].id.to_string(), "guide");
17 Ok(())
18}Sourcepub fn list_collections(&self) -> Result<Vec<String>>
pub fn list_collections(&self) -> Result<Vec<String>>
Returns collection names in canonical ascending order.
Source§impl Store
impl Store
Sourcepub fn text_collection<E: Embedder>(
&self,
name: impl Into<String>,
embedder: E,
) -> Result<TextCollection<E>>
pub fn text_collection<E: Embedder>( &self, name: impl Into<String>, embedder: E, ) -> Result<TextCollection<E>>
Opens a text collection bound to the embedder’s stable model identity.
Examples found in repository?
examples/text.rs (line 28)
25fn main() -> git_vdb::Result<()> {
26 let temporary = tempfile::TempDir::new()?;
27 let db = open(temporary.path().join("documents.git"))?;
28 let docs = db.text_collection("docs", ExampleEmbedder)?;
29 docs.upsert_documents([
30 Document::new("east", "A document about the east"),
31 Document::new("north", "A document about the north"),
32 ])?;
33 assert_eq!(
34 docs.search_text("north wind", 1)?[0].id.to_string(),
35 "north"
36 );
37 Ok(())
38}More examples
examples/text_fastembed.rs (line 8)
5fn main() -> git_vdb::Result<()> {
6 let temporary = tempfile::TempDir::new()?;
7 let db = open(temporary.path().join("documents.git"))?;
8 let docs = db.text_collection("docs", FastEmbedder::try_new()?)?;
9 docs.upsert_documents([
10 Document::new("git", "Git-native vector search"),
11 Document::new("fruit", "Fresh fruit at the market"),
12 ])?;
13 let hits = docs.search_text("versioned database search", 1)?;
14 println!("{}", hits[0].id);
15 Ok(())
16}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl UnwindSafe for Store
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more