typesense_rs/models/search_parameters.rs
1// Typesense API
2//
3// An open source search engine for building delightful search experiences.
4//
5// The version of the OpenAPI document: 27.0
6//
7// Generated by: https://openapi-generator.tech
8
9use serde::{Deserialize, Serialize};
10
11use crate::models;
12
13#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
14pub struct SearchParameters {
15 /// The duration (in seconds) that determines how long the search query is
16 /// cached. This value can be set on a per-query basis. Default: 60.
17 #[serde(rename = "cache_ttl", skip_serializing_if = "Option::is_none")]
18 pub cache_ttl: Option<i32>,
19 /// Enable conversational search.
20 #[serde(rename = "conversation", skip_serializing_if = "Option::is_none")]
21 pub conversation: Option<bool>,
22 /// The Id of a previous conversation to continue, this tells Typesense to
23 /// include prior context when communicating with the LLM.
24 #[serde(rename = "conversation_id", skip_serializing_if = "Option::is_none")]
25 pub conversation_id: Option<String>,
26 /// The Id of Conversation Model to be used.
27 #[serde(rename = "conversation_model_id", skip_serializing_if = "Option::is_none")]
28 pub conversation_model_id: Option<String>,
29 #[serde(rename = "drop_tokens_mode", skip_serializing_if = "Option::is_none")]
30 pub drop_tokens_mode: Option<models::DropTokensMode>,
31 /// If the number of results found for a specific query is less than this
32 /// number, Typesense will attempt to drop the tokens in the query until
33 /// enough results are found. Tokens that have the least individual hits are
34 /// dropped first. Set to 0 to disable. Default: 10
35 #[serde(rename = "drop_tokens_threshold", skip_serializing_if = "Option::is_none")]
36 pub drop_tokens_threshold: Option<i32>,
37 /// Flag for enabling/disabling the deprecated, old highlight structure in
38 /// the response. Default: true
39 #[serde(rename = "enable_highlight_v1", skip_serializing_if = "Option::is_none")]
40 pub enable_highlight_v1: Option<bool>,
41 /// If you have some overrides defined but want to disable all of them
42 /// during query time, you can do that by setting this parameter to false
43 #[serde(rename = "enable_overrides", skip_serializing_if = "Option::is_none")]
44 pub enable_overrides: Option<bool>,
45 /// If you have some synonyms defined but want to disable all of them for a
46 /// particular search query, set enable_synonyms to false. Default: true
47 #[serde(rename = "enable_synonyms", skip_serializing_if = "Option::is_none")]
48 pub enable_synonyms: Option<bool>,
49 /// Set this parameter to false to disable typos on alphanumerical query
50 /// tokens. Default: true.
51 #[serde(rename = "enable_typos_for_alpha_numerical_tokens", skip_serializing_if = "Option::is_none")]
52 pub enable_typos_for_alpha_numerical_tokens: Option<bool>,
53 /// Make Typesense disable typos for numerical tokens.
54 #[serde(rename = "enable_typos_for_numerical_tokens", skip_serializing_if = "Option::is_none")]
55 pub enable_typos_for_numerical_tokens: Option<bool>,
56 /// List of fields from the document to exclude in the search result
57 #[serde(rename = "exclude_fields", skip_serializing_if = "Option::is_none")]
58 pub exclude_fields: Option<String>,
59 /// Setting this to true will make Typesense consider all prefixes and typo
60 /// corrections of the words in the query without stopping early when enough
61 /// results are found (drop_tokens_threshold and typo_tokens_threshold
62 /// configurations are ignored).
63 #[serde(rename = "exhaustive_search", skip_serializing_if = "Option::is_none")]
64 pub exhaustive_search: Option<bool>,
65 /// A list of fields that will be used for faceting your results on.
66 /// Separate multiple fields with a comma.
67 #[serde(rename = "facet_by", skip_serializing_if = "Option::is_none")]
68 pub facet_by: Option<String>,
69 /// Facet values that are returned can now be filtered via this parameter.
70 /// The matching facet text is also highlighted. For example, when faceting
71 /// by `category`, you can set `facet_query=category:shoe` to return only
72 /// facet values that contain the prefix \"shoe\".
73 #[serde(rename = "facet_query", skip_serializing_if = "Option::is_none")]
74 pub facet_query: Option<String>,
75 /// Comma separated string of nested facet fields whose parent object should
76 /// be returned in facet response.
77 #[serde(rename = "facet_return_parent", skip_serializing_if = "Option::is_none")]
78 pub facet_return_parent: Option<String>,
79 /// Choose the underlying faceting strategy used. Comma separated string of
80 /// allows values: exhaustive, top_values or automatic (default).
81 #[serde(rename = "facet_strategy", skip_serializing_if = "Option::is_none")]
82 pub facet_strategy: Option<String>,
83 /// Filter conditions for refining youropen api validator search results.
84 /// Separate multiple conditions with &&.
85 #[serde(rename = "filter_by", skip_serializing_if = "Option::is_none")]
86 pub filter_by: Option<String>,
87 /// Whether the filter_by condition of the search query should be applicable
88 /// to curated results (override definitions, pinned hits, hidden hits,
89 /// etc.). Default: false
90 #[serde(rename = "filter_curated_hits", skip_serializing_if = "Option::is_none")]
91 pub filter_curated_hits: Option<bool>,
92 /// You can aggregate search results into groups or buckets by specify one
93 /// or more `group_by` fields. Separate multiple fields with a comma. To
94 /// group on a particular field, it must be a faceted field.
95 #[serde(rename = "group_by", skip_serializing_if = "Option::is_none")]
96 pub group_by: Option<String>,
97 /// Maximum number of hits to be returned for every group. If the
98 /// `group_limit` is set as `K` then only the top K hits in each group are
99 /// returned in the response. Default: 3
100 #[serde(rename = "group_limit", skip_serializing_if = "Option::is_none")]
101 pub group_limit: Option<i32>,
102 /// Setting this parameter to true will place all documents that have a null
103 /// value in the group_by field, into a single group. Setting this parameter
104 /// to false, will cause each document with a null value in the group_by
105 /// field to not be grouped with other documents. Default: true
106 #[serde(rename = "group_missing_values", skip_serializing_if = "Option::is_none")]
107 pub group_missing_values: Option<bool>,
108 /// A list of records to unconditionally hide from search results. A list of
109 /// `record_id`s to hide. Eg: to hide records with IDs 123 and 456, you'd
110 /// specify `123,456`. You could also use the Overrides feature to override
111 /// search results based on rules. Overrides are applied first, followed by
112 /// `pinned_hits` and finally `hidden_hits`.
113 #[serde(rename = "hidden_hits", skip_serializing_if = "Option::is_none")]
114 pub hidden_hits: Option<String>,
115 /// The number of tokens that should surround the highlighted text on each
116 /// side. Default: 4
117 #[serde(rename = "highlight_affix_num_tokens", skip_serializing_if = "Option::is_none")]
118 pub highlight_affix_num_tokens: Option<i32>,
119 /// The end tag used for the highlighted snippets. Default: `</mark>`
120 #[serde(rename = "highlight_end_tag", skip_serializing_if = "Option::is_none")]
121 pub highlight_end_tag: Option<String>,
122 /// A list of custom fields that must be highlighted even if you don't query
123 /// for them
124 #[serde(rename = "highlight_fields", skip_serializing_if = "Option::is_none")]
125 pub highlight_fields: Option<String>,
126 /// List of fields which should be highlighted fully without snippeting
127 #[serde(rename = "highlight_full_fields", skip_serializing_if = "Option::is_none")]
128 pub highlight_full_fields: Option<String>,
129 /// The start tag used for the highlighted snippets. Default: `<mark>`
130 #[serde(rename = "highlight_start_tag", skip_serializing_if = "Option::is_none")]
131 pub highlight_start_tag: Option<String>,
132 /// List of fields from the document to include in the search result
133 #[serde(rename = "include_fields", skip_serializing_if = "Option::is_none")]
134 pub include_fields: Option<String>,
135 /// If infix index is enabled for this field, infix searching can be done on
136 /// a per-field basis by sending a comma separated string parameter called
137 /// infix to the search query. This parameter can have 3 values; `off` infix
138 /// search is disabled, which is default `always` infix search is performed
139 /// along with regular search `fallback` infix search is performed if
140 /// regular search does not produce results
141 #[serde(rename = "infix", skip_serializing_if = "Option::is_none")]
142 pub infix: Option<String>,
143 /// Number of hits to fetch. Can be used as an alternative to the per_page
144 /// parameter. Default: 10.
145 #[serde(rename = "limit", skip_serializing_if = "Option::is_none")]
146 pub limit: Option<i32>,
147 /// Control the number of words that Typesense considers for typo and prefix
148 /// searching.
149 #[serde(rename = "max_candidates", skip_serializing_if = "Option::is_none")]
150 pub max_candidates: Option<i32>,
151 /// There are also 2 parameters that allow you to control the extent of
152 /// infix searching max_extra_prefix and max_extra_suffix which specify the
153 /// maximum number of symbols before or after the query that can be present
154 /// in the token. For example query \"K2100\" has 2 extra symbols in
155 /// \"6PK2100\". By default, any number of prefixes/suffixes can be present
156 /// for a match.
157 #[serde(rename = "max_extra_prefix", skip_serializing_if = "Option::is_none")]
158 pub max_extra_prefix: Option<i32>,
159 /// There are also 2 parameters that allow you to control the extent of
160 /// infix searching max_extra_prefix and max_extra_suffix which specify the
161 /// maximum number of symbols before or after the query that can be present
162 /// in the token. For example query \"K2100\" has 2 extra symbols in
163 /// \"6PK2100\". By default, any number of prefixes/suffixes can be present
164 /// for a match.
165 #[serde(rename = "max_extra_suffix", skip_serializing_if = "Option::is_none")]
166 pub max_extra_suffix: Option<i32>,
167 /// Maximum number of facet values to be returned.
168 #[serde(rename = "max_facet_values", skip_serializing_if = "Option::is_none")]
169 pub max_facet_values: Option<i32>,
170 /// Minimum word length for 1-typo correction to be applied. The value of
171 /// num_typos is still treated as the maximum allowed typos.
172 #[serde(rename = "min_len_1typo", skip_serializing_if = "Option::is_none")]
173 pub min_len_1typo: Option<i32>,
174 /// Minimum word length for 2-typo correction to be applied. The value of
175 /// num_typos is still treated as the maximum allowed typos.
176 #[serde(rename = "min_len_2typo", skip_serializing_if = "Option::is_none")]
177 pub min_len_2typo: Option<i32>,
178 /// The number of typographical errors (1 or 2) that would be tolerated.
179 /// Default: 2
180 #[serde(rename = "num_typos", skip_serializing_if = "Option::is_none")]
181 pub num_typos: Option<String>,
182 /// Identifies the starting point to return hits from a result set. Can be
183 /// used as an alternative to the page parameter.
184 #[serde(rename = "offset", skip_serializing_if = "Option::is_none")]
185 pub offset: Option<i32>,
186 /// Comma separated list of tags to trigger the curations rules that match
187 /// the tags.
188 #[serde(rename = "override_tags", skip_serializing_if = "Option::is_none")]
189 pub override_tags: Option<String>,
190 /// Results from this specific page number would be fetched.
191 #[serde(rename = "page", skip_serializing_if = "Option::is_none")]
192 pub page: Option<i32>,
193 /// Number of results to fetch per page. Default: 10
194 #[serde(rename = "per_page", skip_serializing_if = "Option::is_none")]
195 pub per_page: Option<i32>,
196 /// A list of records to unconditionally include in the search results at
197 /// specific positions. An example use case would be to feature or promote
198 /// certain items on the top of search results. A list of
199 /// `record_id:hit_position`. Eg: to include a record with ID 123 at
200 /// Position 1 and another record with ID 456 at Position 5, you'd specify
201 /// `123:1,456:5`. You could also use the Overrides feature to override
202 /// search results based on rules. Overrides are applied first, followed by
203 /// `pinned_hits` and finally `hidden_hits`.
204 #[serde(rename = "pinned_hits", skip_serializing_if = "Option::is_none")]
205 pub pinned_hits: Option<String>,
206 /// You can index content from any logographic language into Typesense if
207 /// you are able to segment / split the text into space-separated words
208 /// yourself before indexing and querying. Set this parameter to true to do
209 /// the same
210 #[serde(rename = "pre_segmented_query", skip_serializing_if = "Option::is_none")]
211 pub pre_segmented_query: Option<bool>,
212 /// Boolean field to indicate that the last word in the query should be
213 /// treated as a prefix, and not as a whole word. This is used for building
214 /// autocomplete and instant search interfaces. Defaults to true.
215 #[serde(rename = "prefix", skip_serializing_if = "Option::is_none")]
216 pub prefix: Option<String>,
217 /// Search using a bunch of search parameters by setting this parameter to
218 /// the name of the existing Preset.
219 #[serde(rename = "preset", skip_serializing_if = "Option::is_none")]
220 pub preset: Option<String>,
221 /// Set this parameter to true to ensure that an exact match is ranked above
222 /// the others
223 #[serde(rename = "prioritize_exact_match", skip_serializing_if = "Option::is_none")]
224 pub prioritize_exact_match: Option<bool>,
225 /// Make Typesense prioritize documents where the query words appear in more
226 /// number of fields.
227 #[serde(rename = "prioritize_num_matching_fields", skip_serializing_if = "Option::is_none")]
228 pub prioritize_num_matching_fields: Option<bool>,
229 /// Make Typesense prioritize documents where the query words appear earlier
230 /// in the text.
231 #[serde(rename = "prioritize_token_position", skip_serializing_if = "Option::is_none")]
232 pub prioritize_token_position: Option<bool>,
233 /// The query text to search for in the collection. Use * as the search
234 /// string to return all documents. This is typically useful when used in
235 /// conjunction with filter_by.
236 #[serde(rename = "q")]
237 pub q: String,
238 /// A list of `string` fields that should be queried against. Multiple
239 /// fields are separated with a comma.
240 #[serde(rename = "query_by")]
241 pub query_by: String,
242 /// The relative weight to give each `query_by` field when ranking results.
243 /// This can be used to boost fields in priority, when looking for matches.
244 /// Multiple fields are separated with a comma.
245 #[serde(rename = "query_by_weights", skip_serializing_if = "Option::is_none")]
246 pub query_by_weights: Option<String>,
247 /// Number of times to retry fetching remote embeddings.
248 #[serde(rename = "remote_embedding_num_tries", skip_serializing_if = "Option::is_none")]
249 pub remote_embedding_num_tries: Option<i32>,
250 /// Timeout (in milliseconds) for fetching remote embeddings.
251 #[serde(rename = "remote_embedding_timeout_ms", skip_serializing_if = "Option::is_none")]
252 pub remote_embedding_timeout_ms: Option<i32>,
253 /// Typesense will attempt to return results early if the cutoff time has
254 /// elapsed. This is not a strict guarantee and facet computation is not
255 /// bound by this parameter.
256 #[serde(rename = "search_cutoff_ms", skip_serializing_if = "Option::is_none")]
257 pub search_cutoff_ms: Option<i32>,
258 /// Field values under this length will be fully highlighted, instead of
259 /// showing a snippet of relevant portion. Default: 30
260 #[serde(rename = "snippet_threshold", skip_serializing_if = "Option::is_none")]
261 pub snippet_threshold: Option<i32>,
262 /// A list of numerical fields and their corresponding sort orders that will
263 /// be used for ordering your results. Up to 3 sort fields can be specified.
264 /// The text similarity score is exposed as a special `_text_match` field
265 /// that you can use in the list of sorting fields. If no `sort_by`
266 /// parameter is specified, results are sorted by
267 /// `_text_match:desc,default_sorting_field:desc`
268 #[serde(rename = "sort_by", skip_serializing_if = "Option::is_none")]
269 pub sort_by: Option<String>,
270 /// Treat space as typo: search for q=basket ball if q=basketball is not
271 /// found or vice-versa. Splitting/joining of tokens will only be attempted
272 /// if the original query produces no results. To always trigger this
273 /// behavior, set value to `always``. To disable, set value to `off`.
274 /// Default is `fallback`.
275 #[serde(rename = "split_join_tokens", skip_serializing_if = "Option::is_none")]
276 pub split_join_tokens: Option<String>,
277 /// Name of the stopwords set to apply for this search, the keywords present
278 /// in the set will be removed from the search query.
279 #[serde(rename = "stopwords", skip_serializing_if = "Option::is_none")]
280 pub stopwords: Option<String>,
281 /// Allow synonym resolution on typo-corrected words in the query. Default:
282 /// 0
283 #[serde(rename = "synonym_num_typos", skip_serializing_if = "Option::is_none")]
284 pub synonym_num_typos: Option<i32>,
285 /// Allow synonym resolution on word prefixes in the query. Default: false
286 #[serde(rename = "synonym_prefix", skip_serializing_if = "Option::is_none")]
287 pub synonym_prefix: Option<bool>,
288 /// In a multi-field matching context, this parameter determines how the
289 /// representative text match score of a record is calculated. Possible
290 /// values are max_score (default) or max_weight.
291 #[serde(rename = "text_match_type", skip_serializing_if = "Option::is_none")]
292 pub text_match_type: Option<String>,
293 /// If the number of results found for a specific query is less than this
294 /// number, Typesense will attempt to look for tokens with more typos until
295 /// enough results are found. Default: 100
296 #[serde(rename = "typo_tokens_threshold", skip_serializing_if = "Option::is_none")]
297 pub typo_tokens_threshold: Option<i32>,
298 /// Enable server side caching of search query results. By default, caching
299 /// is disabled.
300 #[serde(rename = "use_cache", skip_serializing_if = "Option::is_none")]
301 pub use_cache: Option<bool>,
302 /// Vector query expression for fetching documents \"closest\" to a given
303 /// query/document vector.
304 #[serde(rename = "vector_query", skip_serializing_if = "Option::is_none")]
305 pub vector_query: Option<String>,
306 /// The base64 encoded audio file in 16 khz 16-bit WAV format.
307 #[serde(rename = "voice_query", skip_serializing_if = "Option::is_none")]
308 pub voice_query: Option<String>,
309}
310
311impl SearchParameters {
312 pub fn new(q: String, query_by: String) -> SearchParameters {
313 SearchParameters {
314 cache_ttl: None,
315 conversation: None,
316 conversation_id: None,
317 conversation_model_id: None,
318 drop_tokens_mode: None,
319 drop_tokens_threshold: None,
320 enable_highlight_v1: None,
321 enable_overrides: None,
322 enable_synonyms: None,
323 enable_typos_for_alpha_numerical_tokens: None,
324 enable_typos_for_numerical_tokens: None,
325 exclude_fields: None,
326 exhaustive_search: None,
327 facet_by: None,
328 facet_query: None,
329 facet_return_parent: None,
330 facet_strategy: None,
331 filter_by: None,
332 filter_curated_hits: None,
333 group_by: None,
334 group_limit: None,
335 group_missing_values: None,
336 hidden_hits: None,
337 highlight_affix_num_tokens: None,
338 highlight_end_tag: None,
339 highlight_fields: None,
340 highlight_full_fields: None,
341 highlight_start_tag: None,
342 include_fields: None,
343 infix: None,
344 limit: None,
345 max_candidates: None,
346 max_extra_prefix: None,
347 max_extra_suffix: None,
348 max_facet_values: None,
349 min_len_1typo: None,
350 min_len_2typo: None,
351 num_typos: None,
352 offset: None,
353 override_tags: None,
354 page: None,
355 per_page: None,
356 pinned_hits: None,
357 pre_segmented_query: None,
358 prefix: None,
359 preset: None,
360 prioritize_exact_match: None,
361 prioritize_num_matching_fields: None,
362 prioritize_token_position: None,
363 q,
364 query_by,
365 query_by_weights: None,
366 remote_embedding_num_tries: None,
367 remote_embedding_timeout_ms: None,
368 search_cutoff_ms: None,
369 snippet_threshold: None,
370 sort_by: None,
371 split_join_tokens: None,
372 stopwords: None,
373 synonym_num_typos: None,
374 synonym_prefix: None,
375 text_match_type: None,
376 typo_tokens_threshold: None,
377 use_cache: None,
378 vector_query: None,
379 voice_query: None,
380 }
381 }
382}