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, Default)]
5#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
6pub enum SpatialRelation {
7    /// Return all documents whose `shape` field intersects the query geometry
8    #[default]
9    Intersects,
10
11    /// Return all documents whose `shape` field has nothing in common with the
12    /// query geometry.
13    Disjoint,
14
15    /// Return all documents whose `shape` field is within the query geometry.
16    Within,
17
18    /// Return all documents whose `shape` field contains the query geometry.
19    Contains,
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25    use crate::util::*;
26
27    #[test]
28    fn serialization() {
29        assert_serialize(
30            [
31                SpatialRelation::Intersects,
32                SpatialRelation::Disjoint,
33                SpatialRelation::Within,
34                SpatialRelation::Contains,
35            ],
36            json!(["INTERSECTS", "DISJOINT", "WITHIN", "CONTAINS"]),
37        );
38    }
39}