rust_store_core/
capability.rs1pub const VECTOR_METRICS: [&str; 3] = ["cosine", "l2", "ip"];
4
5pub const APPLICATION_MAX_DIM: u32 = crate::schema::MAX_VECTOR_DIM;
9pub const PGVECTOR_INDEX_MAX_DIM: u32 = 2000;
13pub const ATLAS_INDEX_MAX_DIM: u32 = 4096;
15
16pub struct VectorEnv<'a> {
18 pub backend: &'a str,
19 pub native_ready: bool,
21 pub atlas_index: bool,
23}
24
25pub fn vector_capability(env: VectorEnv<'_>) -> serde_json::Value {
27 let (supported, native, backend, metrics, max_dim) = match env.backend {
28 "postgres" => {
29 if env.native_ready {
30 (true, true, "pgvector", &VECTOR_METRICS[..], PGVECTOR_INDEX_MAX_DIM)
31 } else {
32 (false, false, "pgvector", &[][..], 0)
33 }
34 }
35 "mongodb" => {
36 if env.atlas_index {
37 (true, true, "atlas", &VECTOR_METRICS[..], ATLAS_INDEX_MAX_DIM)
38 } else {
39 (true, false, "mongo", &VECTOR_METRICS[..], APPLICATION_MAX_DIM)
40 }
41 }
42 "mysql" => (true, false, "mysql", &VECTOR_METRICS[..], APPLICATION_MAX_DIM),
43 "sqlite" => (true, false, "sqlite", &VECTOR_METRICS[..], APPLICATION_MAX_DIM),
44 "local" => (true, false, "local", &VECTOR_METRICS[..], APPLICATION_MAX_DIM),
45 "memory" => (true, false, "memory", &VECTOR_METRICS[..], APPLICATION_MAX_DIM),
46 _ => (false, false, "unknown", &[][..], 0),
47 };
48 serde_json::json!({
49 "supported": supported,
50 "native": native,
51 "backend": backend,
52 "metrics": metrics,
53 "maxDim": max_dim,
54 })
55}