1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct VectorPoint {
8 pub id: Uuid,
10
11 pub vector: Vec<f32>,
13
14 pub metadata: HashMap<String, serde_json::Value>,
16}
17
18#[derive(Debug, Clone)]
20pub struct SearchResult {
21 pub id: Uuid,
23
24 pub score: f32,
26
27 pub metadata: HashMap<String, serde_json::Value>,
29}
30
31#[derive(Debug, Clone)]
33pub struct CollectionConfig {
34 pub name: String,
36
37 pub dimension: usize,
39
40 pub distance: DistanceMetric,
42}
43
44#[derive(Debug, Clone, Copy)]
46pub enum DistanceMetric {
47 Cosine,
49 Euclidean,
51 Dot,
53}
54
55impl VectorPoint {
56 pub fn new(id: Uuid, vector: Vec<f32>) -> Self {
58 Self {
59 id,
60 vector,
61 metadata: HashMap::new(),
62 }
63 }
64
65 pub fn with_metadata(mut self, key: impl Into<String>, value: serde_json::Value) -> Self {
67 self.metadata.insert(key.into(), value);
68 self
69 }
70}