Skip to main content

qdrant_client/builders/
datetime_index_params_builder.rs

1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct DatetimeIndexParamsBuilder {
6    /// If true - store index on disk.
7    pub(crate) on_disk: Option<Option<bool>>,
8    /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests.
9    pub(crate) is_principal: Option<Option<bool>>,
10    /// If true - enable HNSW index for this field.
11    pub(crate) enable_hnsw: Option<Option<bool>>,
12    /// Memory placement of the index.
13    pub(crate) memory: Option<Option<i32>>,
14    /// Index every object of this array as a separate entry.
15    pub(crate) nested: Option<Option<String>>,
16}
17
18impl DatetimeIndexParamsBuilder {
19    /// If true - store index on disk.
20    ///
21    /// Deprecated since 1.19.0, use [`memory`](Self::memory) instead.
22    pub fn on_disk(self, value: bool) -> Self {
23        let mut new = self;
24        new.on_disk = Option::Some(Option::Some(value));
25        new
26    }
27    /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests.
28    pub fn is_principal(self, value: bool) -> Self {
29        let mut new = self;
30        new.is_principal = Option::Some(Option::Some(value));
31        new
32    }
33    /// If true - enable HNSW index for this field.
34    pub fn enable_hnsw(self, value: bool) -> Self {
35        let mut new = self;
36        new.enable_hnsw = Option::Some(Option::Some(value));
37        new
38    }
39    /// Memory placement of the index.
40    /// Overrides the deprecated `on_disk` flag if both are set.
41    pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
42        let mut new = self;
43        new.memory = Option::Some(Option::Some(value.into()));
44        new
45    }
46    /// Index every object of this array as a separate entry, e.g. `offers` for the field `offers[].price`.
47    /// The field must be inside the array's elements.
48    pub fn nested(self, value: impl Into<String>) -> Self {
49        let mut new = self;
50        new.nested = Option::Some(Option::Some(value.into()));
51        new
52    }
53
54    #[allow(deprecated)]
55    fn build_inner(self) -> Result<DatetimeIndexParams, std::convert::Infallible> {
56        Ok(DatetimeIndexParams {
57            on_disk: self.on_disk.unwrap_or_default(),
58            is_principal: self.is_principal.unwrap_or_default(),
59            enable_hnsw: self.enable_hnsw.unwrap_or_default(),
60            memory: self.memory.unwrap_or_default(),
61            nested: self.nested.unwrap_or_default(),
62        })
63    }
64    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
65    fn create_empty() -> Self {
66        Self {
67            on_disk: core::default::Default::default(),
68            is_principal: core::default::Default::default(),
69            enable_hnsw: core::default::Default::default(),
70            memory: core::default::Default::default(),
71            nested: core::default::Default::default(),
72        }
73    }
74}
75
76impl Default for DatetimeIndexParamsBuilder {
77    fn default() -> Self {
78        Self::create_empty()
79    }
80}
81
82impl From<DatetimeIndexParamsBuilder> for DatetimeIndexParams {
83    fn from(value: DatetimeIndexParamsBuilder) -> Self {
84        value.build_inner().unwrap_or_else(|_| {
85            panic!(
86                "Failed to convert {0} to {1}",
87                "DatetimeIndexParamsBuilder", "DatetimeIndexParams"
88            )
89        })
90    }
91}
92
93impl DatetimeIndexParamsBuilder {
94    /// Builds the desired type. Can often be omitted.
95    pub fn build(self) -> DatetimeIndexParams {
96        self.build_inner().unwrap_or_else(|_| {
97            panic!(
98                "Failed to build {0} into {1}",
99                "DatetimeIndexParamsBuilder", "DatetimeIndexParams"
100            )
101        })
102    }
103}