trieve_client/models/
search_chunks_req_payload.rs

1/*
2 * Trieve API
3 *
4 * Trieve OpenAPI Specification. This document describes all of the operations available through the Trieve API.
5 *
6 * The version of the OpenAPI document: 0.11.7
7 * Contact: developers@trieve.ai
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12
13#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
14pub struct SearchChunksReqPayload {
15    /// Set content_only to true to only returning the chunk_html of the chunks. This is useful for when you want to reduce amount of data over the wire for latency improvement (typically 10-50ms). Default is false.
16    #[serde(rename = "content_only", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
17    pub content_only: Option<Option<bool>>,
18    #[serde(rename = "filters", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
19    pub filters: Option<Option<Box<models::ChunkFilter>>>,
20    /// Get total page count for the query accounting for the applied filters. Defaults to false, but can be set to true when the latency penalty is acceptable (typically 50-200ms).
21    #[serde(rename = "get_total_pages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
22    pub get_total_pages: Option<Option<bool>>,
23    #[serde(rename = "highlight_options", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
24    pub highlight_options: Option<Option<Box<models::HighlightOptions>>>,
25    /// Page of chunks to fetch. Page is 1-indexed.
26    #[serde(rename = "page", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
27    pub page: Option<Option<i64>>,
28    /// Page size is the number of chunks to fetch. This can be used to fetch more than 10 chunks at a time.
29    #[serde(rename = "page_size", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
30    pub page_size: Option<Option<i64>>,
31    #[serde(rename = "query")]
32    pub query: Box<models::QueryTypes>,
33    /// If true, stop words (specified in server/src/stop-words.txt in the git repo) will be removed. Queries that are entirely stop words will be preserved.
34    #[serde(rename = "remove_stop_words", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
35    pub remove_stop_words: Option<Option<bool>>,
36    /// Set score_threshold to a float to filter out chunks with a score below the threshold for cosine distance metric For Manhattan Distance, Euclidean Distance, and Dot Product, it will filter out scores above the threshold distance This threshold applies before weight and bias modifications. If not specified, this defaults to no threshold A threshold of 0 will default to no threashold
37    #[serde(rename = "score_threshold", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
38    pub score_threshold: Option<Option<f32>>,
39    #[serde(rename = "search_type")]
40    pub search_type: models::SearchMethod,
41    /// Set slim_chunks to true to avoid returning the content and chunk_html of the chunks. This is useful for when you want to reduce amount of data over the wire for latency improvement (typically 10-50ms). Default is false.
42    #[serde(rename = "slim_chunks", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
43    pub slim_chunks: Option<Option<bool>>,
44    #[serde(rename = "sort_options", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
45    pub sort_options: Option<Option<Box<models::SortOptions>>>,
46    /// If true, quoted and - prefixed words will be parsed from the queries and used as required and negated words respectively. Default is false.
47    #[serde(rename = "use_quote_negated_terms", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
48    pub use_quote_negated_terms: Option<Option<bool>>,
49    /// User ID is the id of the user who is making the request. This is used to track user interactions with the search results.
50    #[serde(rename = "user_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
51    pub user_id: Option<Option<String>>,
52}
53
54impl SearchChunksReqPayload {
55    pub fn new(query: models::QueryTypes, search_type: models::SearchMethod) -> SearchChunksReqPayload {
56        SearchChunksReqPayload {
57            content_only: None,
58            filters: None,
59            get_total_pages: None,
60            highlight_options: None,
61            page: None,
62            page_size: None,
63            query: Box::new(query),
64            remove_stop_words: None,
65            score_threshold: None,
66            search_type,
67            slim_chunks: None,
68            sort_options: None,
69            use_quote_negated_terms: None,
70            user_id: None,
71        }
72    }
73}
74