qdrant_client/builders/
prefetch_query_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct PrefetchQueryBuilder {
5 pub(crate) prefetch: Option<Vec<PrefetchQuery>>,
7 pub(crate) query: Option<Option<Query>>,
9 pub(crate) using: Option<Option<String>>,
11 pub(crate) filter: Option<Option<Filter>>,
13 pub(crate) params: Option<Option<SearchParams>>,
15 pub(crate) score_threshold: Option<Option<f32>>,
17 pub(crate) limit: Option<Option<u64>>,
19 pub(crate) lookup_from: Option<Option<LookupLocation>>,
21}
22
23impl PrefetchQueryBuilder {
24 pub fn prefetch<VALUE: core::convert::Into<Vec<PrefetchQuery>>>(self, value: VALUE) -> Self {
26 let mut new = self;
27 new.prefetch = Option::Some(value.into());
28 new
29 }
30 pub fn query<VALUE: core::convert::Into<Query>>(self, value: VALUE) -> Self {
32 let mut new = self;
33 new.query = Option::Some(Option::Some(value.into()));
34 new
35 }
36 pub fn using<VALUE: core::convert::Into<String>>(self, value: VALUE) -> Self {
38 let mut new = self;
39 new.using = Option::Some(Option::Some(value.into()));
40 new
41 }
42 pub fn filter<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
44 let mut new = self;
45 new.filter = Option::Some(Option::Some(value.into()));
46 new
47 }
48 pub fn params<VALUE: core::convert::Into<SearchParams>>(self, value: VALUE) -> Self {
50 let mut new = self;
51 new.params = Option::Some(Option::Some(value.into()));
52 new
53 }
54 pub fn score_threshold<VALUE: core::convert::Into<f32>>(self, value: VALUE) -> Self {
56 let mut new = self;
57 new.score_threshold = Option::Some(Option::Some(value.into()));
58 new
59 }
60 pub fn limit<VALUE: core::convert::Into<u64>>(self, value: VALUE) -> Self {
62 let mut new = self;
63 new.limit = Option::Some(Option::Some(value.into()));
64 new
65 }
66 pub fn lookup_from<VALUE: core::convert::Into<LookupLocation>>(self, value: VALUE) -> Self {
68 let mut new = self;
69 new.lookup_from = Option::Some(Option::Some(value.into()));
70 new
71 }
72
73 fn build_inner(self) -> Result<PrefetchQuery, std::convert::Infallible> {
74 Ok(PrefetchQuery {
75 prefetch: self.prefetch.unwrap_or_default(),
76 query: self.query.unwrap_or_default(),
77 using: self.using.unwrap_or_default(),
78 filter: self.filter.unwrap_or_default(),
79 params: self.params.unwrap_or_default(),
80 score_threshold: self.score_threshold.unwrap_or_default(),
81 limit: self.limit.unwrap_or_default(),
82 lookup_from: self.lookup_from.unwrap_or_default(),
83 })
84 }
85 fn create_empty() -> Self {
87 Self {
88 prefetch: core::default::Default::default(),
89 query: core::default::Default::default(),
90 using: core::default::Default::default(),
91 filter: core::default::Default::default(),
92 params: core::default::Default::default(),
93 score_threshold: core::default::Default::default(),
94 limit: core::default::Default::default(),
95 lookup_from: core::default::Default::default(),
96 }
97 }
98}
99
100impl From<PrefetchQueryBuilder> for PrefetchQuery {
101 fn from(value: PrefetchQueryBuilder) -> Self {
102 value.build_inner().unwrap_or_else(|_| {
103 panic!(
104 "Failed to convert {0} to {1}",
105 "PrefetchQueryBuilder", "PrefetchQuery"
106 )
107 })
108 }
109}
110
111impl PrefetchQueryBuilder {
112 pub fn build(self) -> PrefetchQuery {
114 self.build_inner().unwrap_or_else(|_| {
115 panic!(
116 "Failed to build {0} into {1}",
117 "PrefetchQueryBuilder", "PrefetchQuery"
118 )
119 })
120 }
121}
122
123impl Default for PrefetchQueryBuilder {
124 fn default() -> Self {
125 Self::create_empty()
126 }
127}