elasticsearch_dsl/search/queries/params/
shape_query.rs

1use serde::Serialize;
2
3/// Relation between coordinates
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
5#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
6pub enum SpatialRelation {
7    /// Return all documents whose `shape` field intersects the query geometry
8    Intersects,
9
10    /// Return all documents whose `shape` field has nothing in common with the
11    /// query geometry.
12    Disjoint,
13
14    /// Return all documents whose `shape` field is within the query geometry.
15    Within,
16
17    /// Return all documents whose `shape` field contains the query geometry.
18    Contains,
19}
20
21impl Default for SpatialRelation {
22    fn default() -> Self {
23        Self::Intersects
24    }
25}
26
27#[cfg(test)]
28mod tests {
29    use super::*;
30    use crate::util::*;
31
32    #[test]
33    fn serialization() {
34        assert_serialize(
35            [
36                SpatialRelation::Intersects,
37                SpatialRelation::Disjoint,
38                SpatialRelation::Within,
39                SpatialRelation::Contains,
40            ],
41            json!(["INTERSECTS", "DISJOINT", "WITHIN", "CONTAINS"]),
42        );
43    }
44}