elasticsearch_dsl/search/queries/
match_all_query.rs1use super::Query;
2use crate::util::*;
3
4#[derive(Debug, Clone, PartialEq, Serialize, Default)]
18#[serde(remote = "Self")]
19pub struct MatchAllQuery {
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
27serialize_with_root!("match_all": MatchAllQuery);
28
29impl Query {
30 pub fn match_all() -> MatchAllQuery {
32 MatchAllQuery::default()
33 }
34}
35
36impl MatchAllQuery {
37 add_boost_and_name!();
38}
39
40impl ShouldSkip for MatchAllQuery {}
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn serialization() {
48 assert_serialize_query(Query::match_all(), json!({ "match_all": {} }));
49
50 assert_serialize_query(
51 Query::match_all().boost(2).name("test"),
52 json!({ "match_all": { "boost": 2.0, "_name": "test" } }),
53 );
54 }
55}