Skip to main content

text_fastembed/
text_fastembed.rs

1#[cfg(feature = "fastembed")]
2use git_vdb::{open, Document, FastEmbedder};
3
4#[cfg(feature = "fastembed")]
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}
17
18#[cfg(not(feature = "fastembed"))]
19fn main() {
20    eprintln!("run with --features fastembed");
21}