use super::Query;
use crate::util::*;
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[serde(remote = "Self")]
pub struct MatchAllQuery {
#[serde(skip_serializing_if = "ShouldSkip::should_skip")]
boost: Option<f32>,
#[serde(skip_serializing_if = "ShouldSkip::should_skip")]
_name: Option<String>,
}
serialize_with_root!("match_all": MatchAllQuery);
impl Query {
pub fn match_all() -> MatchAllQuery {
MatchAllQuery::default()
}
}
impl MatchAllQuery {
add_boost_and_name!();
}
impl ShouldSkip for MatchAllQuery {}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn serialization() {
assert_serialize_query(Query::match_all(), json!({ "match_all": {} }));
assert_serialize_query(
Query::match_all().boost(2).name("test"),
json!({ "match_all": { "boost": 2.0, "_name": "test" } }),
);
}
}