1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/// Special sorting field variants
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
pub enum SortSpecialField {
    /// Document score
    #[serde(rename = "_score")]
    Score,

    /// The most efficient way to sort, does not guarantee any order, useful for scrolling
    #[serde(rename = "_doc")]
    DocumentIndexOrder,

    /// Sorts by shard doc value, useful for PIT queries
    #[serde(rename = "_shard_doc")]
    ShardDocumentOrder,
}

impl ToString for SortSpecialField {
    fn to_string(&self) -> String {
        String::from(match self {
            Self::Score => "_score",
            Self::DocumentIndexOrder => "_doc",
            Self::ShardDocumentOrder => "_shard_doc",
        })
    }
}