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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Settings {
#[serde(skip_serializing_if = "Option::is_none")]
pub synonyms: Option<HashMap<String, Vec<String>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stop_words: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ranking_rules: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub distinct_attribute: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub searchable_attributes: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub displayed_attributes: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub accept_new_fields: Option<bool>,
}
#[allow(missing_docs)]
impl Settings {
pub fn new() -> Settings {
Settings {
synonyms: None,
stop_words: None,
ranking_rules: None,
distinct_attribute: None,
searchable_attributes: None,
displayed_attributes: None,
accept_new_fields: None,
}
}
pub fn with_synonyms(self, synonyms: HashMap<String, Vec<String>>) -> Settings {
Settings {
synonyms: Some(synonyms),
..self
}
}
pub fn with_stop_words(self, stop_words: Vec<String>) -> Settings {
Settings {
stop_words: Some(stop_words),
..self
}
}
pub fn with_ranking_rules(self, ranking_rules: Vec<String>) -> Settings {
Settings {
ranking_rules: Some(ranking_rules),
..self
}
}
pub fn with_distinct_attribute(self, distinct_attribute: String) -> Settings {
Settings {
distinct_attribute: Some(distinct_attribute),
..self
}
}
pub fn with_searchable_attributes(self, searchable_attributes: Vec<String>) -> Settings {
Settings {
searchable_attributes: Some(searchable_attributes),
..self
}
}
pub fn with_displayed_attributes(self, displayed_attributes: Vec<String>) -> Settings {
Settings {
displayed_attributes: Some(displayed_attributes),
..self
}
}
pub fn with_accept_new_fields(self, accept_new_fields: bool) -> Settings {
Settings {
accept_new_fields: Some(accept_new_fields),
..self
}
}
}