@@ -123,6 +123,14 @@ pub struct EncryptOptions {
123123 /// Set the range options. This should only be set when the algorithm is
124124 /// [`Algorithm::Range`].
125125 pub range_options : Option < RangeOptions > ,
126+
127+ /// Set the text options. This should only be set when the algorithm is
128+ /// [`Algorithm::TextPreview`].
129+ ///
130+ /// NOTE: This option is unstable and subject to backwards-breaking changes. It should only be
131+ /// used in experimental workloads.
132+ #[ cfg( feature = "text-indexes-unstable" ) ]
133+ pub text_options : Option < TextOptions > ,
126134}
127135
128136/// The index options for a Queryable Encryption field supporting "range" queries.
@@ -150,6 +158,94 @@ pub struct RangeOptions {
150158 pub precision : Option < i32 > ,
151159}
152160
161+ /// Options for a queryable encryption field supporting text queries.
162+ ///
163+ /// NOTE: These options are unstable and subject to backwards-breaking changes. They should only be
164+ /// used in experimental workloads.
165+ #[ skip_serializing_none]
166+ #[ derive( Clone , Default , Debug , Serialize , TypedBuilder ) ]
167+ #[ serde( rename_all = "camelCase" ) ]
168+ #[ builder( field_defaults( default , setter( into) ) ) ]
169+ #[ non_exhaustive]
170+ #[ cfg( feature = "text-indexes-unstable" ) ]
171+ pub struct TextOptions {
172+ /// Options for substring queries.
173+ pub substring : Option < SubstringOptions > ,
174+
175+ /// Options for prefix queries.
176+ pub prefix : Option < PrefixOptions > ,
177+
178+ /// Options for suffix queries.
179+ pub suffix : Option < SuffixOptions > ,
180+
181+ /// Whether text indexes for this field are case-sensitive.
182+ pub case_sensitive : bool ,
183+
184+ /// Whether text indexes for this field are diacritic-sensitive.
185+ pub diacritic_sensitive : bool ,
186+ }
187+
188+ /// Options for substring queries.
189+ ///
190+ /// NOTE: These options are unstable and subject to backwards-breaking changes. They should only be
191+ /// used in experimental workloads.
192+ #[ derive( Clone , Default , Debug , Serialize , TypedBuilder ) ]
193+ #[ serde( rename_all = "camelCase" ) ]
194+ #[ builder( field_defaults( default , setter( into) ) ) ]
195+ #[ non_exhaustive]
196+ #[ cfg( feature = "text-indexes-unstable" ) ]
197+ pub struct SubstringOptions {
198+ /// The maximum allowed string length. Inserting a longer string will result in an error.
199+ #[ serde( rename = "strMaxLength" ) ]
200+ pub max_string_length : i32 ,
201+
202+ /// The minimum allowed query length. Querying with a shorter string will result in an error.
203+ #[ serde( rename = "strMinQueryLength" ) ]
204+ pub min_query_length : i32 ,
205+
206+ /// The maximum allowed query length. Querying with a longer string will result in an error.
207+ #[ serde( rename = "strMaxQueryLength" ) ]
208+ pub max_query_length : i32 ,
209+ }
210+
211+ /// Options for prefix queries.
212+ ///
213+ /// NOTE: These options are unstable and subject to backwards-breaking changes. They should only be
214+ /// used in experimental workloads.
215+ #[ derive( Clone , Default , Debug , Serialize , TypedBuilder ) ]
216+ #[ serde( rename_all = "camelCase" ) ]
217+ #[ builder( field_defaults( default , setter( into) ) ) ]
218+ #[ non_exhaustive]
219+ #[ cfg( feature = "text-indexes-unstable" ) ]
220+ pub struct PrefixOptions {
221+ /// The minimum allowed query length. Querying with a shorter string will result in an error.
222+ #[ serde( rename = "strMinQueryLength" ) ]
223+ pub min_query_length : i32 ,
224+
225+ /// The maximum allowed query length. Querying with a longer string will result in an error.
226+ #[ serde( rename = "strMaxQueryLength" ) ]
227+ pub max_query_length : i32 ,
228+ }
229+
230+ /// Options for suffix queries.
231+ ///
232+ /// NOTE: These options are unstable and subject to backwards-breaking changes. They should only be
233+ /// used in experimental workloads.
234+ #[ derive( Clone , Default , Debug , Serialize , TypedBuilder ) ]
235+ #[ serde( rename_all = "camelCase" ) ]
236+ #[ builder( field_defaults( default , setter( into) ) ) ]
237+ #[ non_exhaustive]
238+ #[ cfg( feature = "text-indexes-unstable" ) ]
239+ pub struct SuffixOptions {
240+ /// The minimum allowed query length. Querying with a shorter string will result in an error.
241+ #[ serde( rename = "strMinQueryLength" ) ]
242+ pub min_query_length : i32 ,
243+
244+ /// The maximum allowed query length. Querying with a longer string will result in an error.
245+ #[ serde( rename = "strMaxQueryLength" ) ]
246+ pub max_query_length : i32 ,
247+ }
248+
153249#[ option_setters( EncryptOptions , skip = [ query_type] ) ]
154250#[ export_doc( encrypt, extra = [ query_type] ) ]
155251#[ export_doc( encrypt_expr) ]
0 commit comments