qdrant_client/qdrant_client/builders/
sparse_vectors_config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::collections::HashMap;

use crate::qdrant::{SparseVectorConfig, SparseVectorParams};

#[derive(Debug, Clone, Default)]
pub struct SparseVectorsConfigBuilder {
    params: HashMap<String, SparseVectorParams>,
}

impl SparseVectorsConfigBuilder {
    /// Add a named vector with the given parameters
    pub fn add_named_vector_params(
        &mut self,
        name: impl Into<String>,
        params: impl Into<SparseVectorParams>,
    ) -> &mut Self {
        self.params.insert(name.into(), params.into());
        self
    }
}

impl From<SparseVectorsConfigBuilder> for SparseVectorConfig {
    fn from(builder: SparseVectorsConfigBuilder) -> Self {
        if builder.params.is_empty() {
            return SparseVectorConfig::default();
        }

        SparseVectorConfig {
            map: builder.params,
        }
    }
}