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