Skip to main content

velesdb_core/collection/vector_collection/
mod.rs

1//! `VectorCollection`: newtype wrapper around `Collection` for vector workloads.
2//!
3//! This type provides a stable, typed API for vector collections.
4//! Internally it delegates 100% to the `Collection` executor to avoid
5//! any data synchronisation issues between separate storage layers.
6
7mod accessors;
8mod crud;
9mod lifecycle;
10mod search;
11#[cfg(test)]
12mod search_tests;
13
14use crate::collection::types::Collection;
15
16/// A vector collection combining HNSW search, payload storage, and full-text search.
17///
18/// `VectorCollection` is a typed newtype over `Collection` that provides
19/// a stable public API for vector workloads. All storage operations delegate
20/// to the single `inner: Collection` instance — no dual-storage desync.
21///
22/// # Examples
23///
24/// ```rust,no_run
25/// use velesdb_core::{VectorCollection, DistanceMetric, Point, StorageMode};
26/// use serde_json::json;
27///
28/// let coll = VectorCollection::create(
29///     "./data/docs".into(),
30///     "docs",
31///     768,
32///     DistanceMetric::Cosine,
33///     StorageMode::Full,
34/// )?;
35///
36/// coll.upsert(vec![
37///     Point::new(1, vec![0.1; 768], Some(json!({"title": "Hello"}))),
38/// ])?;
39///
40/// let results = coll.search(&vec![0.1; 768], 10)?;
41/// # Ok::<(), velesdb_core::Error>(())
42/// ```
43#[derive(Clone)]
44pub struct VectorCollection {
45    /// Single source of truth — all operations delegate here.
46    pub(crate) inner: Collection,
47}