1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use super::TotalHitsRelation;

/// Total number of matched documents
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct TotalHits {
    /// Number of total documents
    pub value: u64,

    /// Relation to total number of matched documents
    pub relation: TotalHitsRelation,
}

impl TotalHits {
    /// Create default Total instance
    pub fn new(value: Option<u64>) -> Self {
        Self {
            value: value.unwrap_or(0),
            relation: TotalHitsRelation::Equal,
        }
    }
}