elasticsearch_dsl/search/queries/
match_none_query.rs1use super::Query;
2use crate::util::*;
3
4#[derive(Debug, Clone, PartialEq, Serialize, Default)]
18#[serde(remote = "Self")]
19pub struct MatchNoneQuery {
20 #[serde(skip_serializing_if = "ShouldSkip::should_skip")]
21 boost: Option<f32>,
22
23 #[serde(skip_serializing_if = "ShouldSkip::should_skip")]
24 _name: Option<String>,
25}
26
27impl Query {
28 pub fn match_none() -> MatchNoneQuery {
30 MatchNoneQuery::default()
31 }
32}
33
34impl MatchNoneQuery {
35 add_boost_and_name!();
36}
37
38serialize_with_root!("match_none": MatchNoneQuery);
39
40impl ShouldSkip for MatchNoneQuery {}
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn serialization() {
48 assert_serialize_query(Query::match_none(), json!({"match_none": {} }));
49
50 assert_serialize_query(
51 Query::match_none().boost(2).name("test"),
52 json!({ "match_none": { "boost": 2.0, "_name": "test" } }),
53 );
54 }
55}