pub struct CollectionHandle { /* private fields */ }Expand description
A named collection that is created with an inferred dimension on first use.
Implementations§
Source§impl CollectionHandle
impl CollectionHandle
Sourcepub fn upsert(
&self,
points: impl IntoIterator<Item = Point>,
) -> Result<WriteResult>
pub fn upsert( &self, points: impl IntoIterator<Item = Point>, ) -> Result<WriteResult>
Adds or replaces points, creating a missing collection on first write.
The first write infers the collection dimension from its points. All vectors in that batch must be nonempty and have the same dimension.
Examples found in repository?
More examples
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}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 search(
&self,
vector: impl IntoIterator<Item = f32>,
limit: usize,
) -> Result<Vec<ScoredPoint>>
pub fn search( &self, vector: impl IntoIterator<Item = f32>, limit: usize, ) -> Result<Vec<ScoredPoint>>
Searches for the nearest points using the collection’s automatic mode.
Payload metadata is included in every returned winner. Use
CollectionHandle::advanced for filters, stored vectors, immutable
roots, execution statistics, or explicit search tuning.
Examples found in repository?
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}Sourcepub fn query(&self, query: Query) -> Result<QueryResult>
pub fn query(&self, query: Query) -> Result<QueryResult>
Executes a detailed vector query without leaving the common facade.
Sourcepub fn query_batch(
&self,
queries: impl IntoIterator<Item = Query>,
) -> Result<Vec<QueryResult>>
pub fn query_batch( &self, queries: impl IntoIterator<Item = Query>, ) -> Result<Vec<QueryResult>>
Executes detailed vector queries in input order.
Sourcepub fn get(&self, request: GetRequest) -> Result<GetResult>
pub fn get(&self, request: GetRequest) -> Result<GetResult>
Retrieves records using IDs, filters, pagination, and include controls.
Sourcepub fn get_ids(
&self,
ids: impl IntoIterator<Item = PointId>,
) -> Result<Vec<Record>>
pub fn get_ids( &self, ids: impl IntoIterator<Item = PointId>, ) -> Result<Vec<Record>>
Retrieves points by typed ID with payload metadata included.
Sourcepub fn delete_ids(
&self,
ids: impl IntoIterator<Item = PointId>,
) -> Result<WriteResult>
pub fn delete_ids( &self, ids: impl IntoIterator<Item = PointId>, ) -> Result<WriteResult>
Deletes points by typed ID. Missing IDs are ignored.
Sourcepub fn delete(&self, selector: DeleteSelector) -> Result<WriteResult>
pub fn delete(&self, selector: DeleteSelector) -> Result<WriteResult>
Deletes records selected by IDs, a filter, or both.
Sourcepub fn apply(
&self,
mutations: impl IntoIterator<Item = SnapshotMutation>,
) -> Result<MutationResult>
pub fn apply( &self, mutations: impl IntoIterator<Item = SnapshotMutation>, ) -> Result<MutationResult>
Applies an ordered batch of upserts and deletions in one ref update.
Sourcepub fn count_where(&self, filter: Filter) -> Result<usize>
pub fn count_where(&self, filter: Filter) -> Result<usize>
Returns the number of points matching a payload or ID filter.
Sourcepub fn restore(&self, revision: impl AsRef<str>) -> Result<WriteResult>
pub fn restore(&self, revision: impl AsRef<str>) -> Result<WriteResult>
Restores a historical root as a new history-preserving commit.
Sourcepub fn peek(&self, limit: usize) -> Result<Vec<Record>>
pub fn peek(&self, limit: usize) -> Result<Vec<Record>>
Returns the first limit canonically ordered points with payloads.
Sourcepub fn advanced(&self) -> Result<Collection>
pub fn advanced(&self) -> Result<Collection>
Opens the existing collection through the detailed named API.
Examples found in repository?
More examples
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}Trait Implementations§
Source§impl Clone for CollectionHandle
impl Clone for CollectionHandle
Auto Trait Implementations§
impl Freeze for CollectionHandle
impl RefUnwindSafe for CollectionHandle
impl Send for CollectionHandle
impl Sync for CollectionHandle
impl Unpin for CollectionHandle
impl UnsafeUnpin for CollectionHandle
impl UnwindSafe for CollectionHandle
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
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> ⓘ
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> ⓘ
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