opensearch_dsl/search/queries/params/
terms_set_query.rs1use serde_json::Value;
2
3#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
5pub enum TermsSetMinimumShouldMatch {
6 #[serde(rename = "minimum_should_match_field")]
10 Field(String),
11
12 #[serde(rename = "minimum_should_match_script")]
21 Script(TermsSetScript),
22}
23
24impl From<String> for TermsSetMinimumShouldMatch {
25 fn from(field: String) -> Self {
26 Self::Field(field)
27 }
28}
29
30impl<'a> From<&'a str> for TermsSetMinimumShouldMatch {
31 fn from(field: &'a str) -> Self {
32 Self::Field(field.to_string())
33 }
34}
35
36impl From<TermsSetScript> for TermsSetMinimumShouldMatch {
37 fn from(script: TermsSetScript) -> Self {
38 Self::Script(script)
39 }
40}
41
42#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
48pub struct TermsSetScript {
49 source: String,
50 params: Option<Value>,
51}
52
53impl From<String> for TermsSetScript {
54 fn from(source: String) -> Self {
55 Self {
56 source,
57 params: None,
58 }
59 }
60}
61
62impl<'a> From<&'a str> for TermsSetScript {
63 fn from(source: &'a str) -> Self {
64 Self {
65 source: source.to_string(),
66 params: None,
67 }
68 }
69}
70
71impl TermsSetScript {
72 pub fn new<T>(source: T) -> Self
74 where
75 T: ToString,
76 {
77 Self {
78 source: source.to_string(),
79 params: None,
80 }
81 }
82
83 pub fn params(mut self, params: Value) -> Self {
85 self.params = Some(params);
86 self
87 }
88}