-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathsearch_index.rs
75 lines (65 loc) · 2.49 KB
/
search_index.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::bson::Document;
use bson::doc;
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
/// Specifies the options for a search index.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Default, TypedBuilder, Serialize, Deserialize)]
#[builder(field_defaults(default, setter(into)))]
#[non_exhaustive]
pub struct SearchIndexModel {
/// The definition for this index.
pub definition: Document,
/// The name for this index, if present.
pub name: Option<String>,
/// The type for this index, if present.
#[serde(rename = "type")]
pub index_type: Option<SearchIndexType>,
}
/// Specifies the type of search index.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum SearchIndexType {
/// A regular search index.
Search,
/// A vector search index.
VectorSearch,
/// An unknown type of search index.
#[serde(untagged)]
Other(String),
}
pub mod options {
#[cfg(docsrs)]
use crate::Collection;
use macro_magic::export_tokens;
use serde::Deserialize;
use typed_builder::TypedBuilder;
/// Options for [Collection::create_search_index]. Present to allow additional options to be
/// added in the future as a non-breaking change.
#[derive(Clone, Debug, Default, TypedBuilder, Deserialize)]
#[builder(field_defaults(default, setter(into)))]
#[non_exhaustive]
#[export_tokens]
pub struct CreateSearchIndexOptions {}
/// Options for [Collection::update_search_index]. Present to allow additional options to be
/// added in the future as a non-breaking change.
#[derive(Clone, Debug, Default, TypedBuilder, Deserialize)]
#[builder(field_defaults(default, setter(into)))]
#[non_exhaustive]
#[export_tokens]
pub struct UpdateSearchIndexOptions {}
/// Options for [Collection::list_search_indexes]. Present to allow additional options to be
/// added in the future as a non-breaking change.
#[derive(Clone, Debug, Default, TypedBuilder, Deserialize)]
#[builder(field_defaults(default, setter(into)))]
#[non_exhaustive]
#[export_tokens]
pub struct ListSearchIndexOptions {}
/// Options for [Collection::drop_search_index]. Present to allow additional options to be
/// added in the future as a non-breaking change.
#[derive(Clone, Debug, Default, TypedBuilder, Deserialize)]
#[builder(field_defaults(default, setter(into)))]
#[non_exhaustive]
#[export_tokens]
pub struct DropSearchIndexOptions {}
}