pub struct TextCollection<E> { /* private fields */ }Expand description
A collection that embeds documents and text queries with one model.
Implementations§
Source§impl<E: Embedder> TextCollection<E>
impl<E: Embedder> TextCollection<E>
Sourcepub fn upsert_documents(
&self,
documents: impl IntoIterator<Item = Document>,
) -> Result<WriteResult>
pub fn upsert_documents( &self, documents: impl IntoIterator<Item = Document>, ) -> Result<WriteResult>
Embeds and upserts documents, retaining their text in each payload.
Examples found in repository?
examples/text.rs (lines 29-32)
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 (lines 9-12)
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}Sourcepub fn replace_documents(
&self,
filter: Filter,
documents: impl IntoIterator<Item = Document>,
) -> Result<MutationResult>
pub fn replace_documents( &self, filter: Filter, documents: impl IntoIterator<Item = Document>, ) -> Result<MutationResult>
Atomically replaces documents matching filter with a new document set.
The collection must already exist. Use TextCollection::upsert_documents
for the first write, then this method for repeatable source synchronization.
Sourcepub fn delete(&self, selector: DeleteSelector) -> Result<WriteResult>
pub fn delete(&self, selector: DeleteSelector) -> Result<WriteResult>
Deletes text documents selected by IDs, metadata, or document filters.
Sourcepub fn search_text(
&self,
text: impl Into<String>,
limit: usize,
) -> Result<Vec<ScoredPoint>>
pub fn search_text( &self, text: impl Into<String>, limit: usize, ) -> Result<Vec<ScoredPoint>>
Embeds one text query and returns nearest documents with payloads.
Examples found in repository?
examples/text.rs (line 34)
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 13)
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}Sourcepub fn query(&self, query: TextQuery) -> Result<Vec<DocumentHit>>
pub fn query(&self, query: TextQuery) -> Result<Vec<DocumentHit>>
Embeds and executes one filtered text query, returning typed documents.
Sourcepub fn query_batch(
&self,
queries: impl IntoIterator<Item = TextQuery>,
) -> Result<Vec<Vec<DocumentHit>>>
pub fn query_batch( &self, queries: impl IntoIterator<Item = TextQuery>, ) -> Result<Vec<Vec<DocumentHit>>>
Embeds and executes text queries in input order as one embedding batch.
Sourcepub fn vectors(&self) -> &CollectionHandle
pub fn vectors(&self) -> &CollectionHandle
Returns the underlying vector collection handle.
Trait Implementations§
Source§impl<E: Clone> Clone for TextCollection<E>
impl<E: Clone> Clone for TextCollection<E>
Auto Trait Implementations§
impl<E> Freeze for TextCollection<E>where
E: Freeze,
impl<E> RefUnwindSafe for TextCollection<E>where
E: RefUnwindSafe,
impl<E> Send for TextCollection<E>where
E: Send,
impl<E> Sync for TextCollection<E>where
E: Sync,
impl<E> Unpin for TextCollection<E>where
E: Unpin,
impl<E> UnsafeUnpin for TextCollection<E>where
E: UnsafeUnpin,
impl<E> UnwindSafe for TextCollection<E>where
E: UnwindSafe,
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