update the syntax of the geoboundingbox filter to uses brackets instead of parens around lat and lng

This commit is contained in:
Tamo 2023-02-06 16:50:27 +01:00
parent 3ebc99473f
commit 1b005f697d
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
5 changed files with 35 additions and 35 deletions

View file

@ -161,7 +161,7 @@ mod tests {
("_geoRadius(42, 75, 59):asc", ReservedNameForFilter { name: S("_geoRadius") }),
("_geoBoundingBox:asc", ReservedNameForFilter { name: S("_geoBoundingBox") }),
(
"_geoBoundingBox((42, 75), (75, 59)):asc",
"_geoBoundingBox([42, 75], [75, 59]):asc",
ReservedNameForFilter { name: S("_geoBoundingBox") },
),
];

View file

@ -1529,63 +1529,63 @@ pub(crate) mod tests {
// exact match a document
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((0, 0), (0, 0))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([0, 0], [0, 0])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[0]>");
// match a document in the middle of the rectangle
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((10, -10), (-10, 10))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([10, -10], [-10, 10])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[0]>");
// select everything
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((90, -180), (-90, 180))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([90, -180], [-90, 180])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[0, 1, 2, 3, 4]>");
// go on the edge of the longitude
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((0, 180), (0, -170))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([0, 180], [0, -170])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[1]>");
// go on the other edge of the longitude
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((0, 170), (0, -180))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([0, 170], [0, -180])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[2]>");
// wrap around the longitude
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((0, 170), (0, -170))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([0, 170], [0, -170])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[1, 2]>");
// go on the edge of the latitude
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((90, 0), (80, 0))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([90, 0], [80, 0])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[3]>");
// go on the edge of the latitude
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((-80, 0), (-90, 0))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([-80, 0], [-90, 0])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[4]>");
// try to wrap around the latitude
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((-80, 0), (80, 0))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([-80, 0], [80, 0])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[]>");
@ -1593,7 +1593,7 @@ pub(crate) mod tests {
// the request that doesn't make sense
// send a top latitude lower than the bottow latitude
let search_result = search
.filter(Filter::from_str("_geoBoundingBox((-10, 0), (10, 0))").unwrap().unwrap())
.filter(Filter::from_str("_geoBoundingBox([-10, 0], [10, 0])").unwrap().unwrap())
.execute()
.unwrap();
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[]>");

View file

@ -619,7 +619,7 @@ mod tests {
"Attribute `_geo` is not filterable. This index does not have configured filterable attributes."
));
let filter = Filter::from_str("_geoBoundingBox((42, 150), (30, 10))").unwrap().unwrap();
let filter = Filter::from_str("_geoBoundingBox([42, 150], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().starts_with(
"Attribute `_geo` is not filterable. This index does not have configured filterable attributes."
@ -647,7 +647,7 @@ mod tests {
"Attribute `_geo` is not filterable. Available filterable attributes are: `title`."
));
let filter = Filter::from_str("_geoBoundingBox((42, 150), (30, 10))").unwrap().unwrap();
let filter = Filter::from_str("_geoBoundingBox([42, 150], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().starts_with(
"Attribute `_geo` is not filterable. Available filterable attributes are: `title`."
@ -819,7 +819,7 @@ mod tests {
// geoboundingbox top left coord have a bad latitude
let filter =
Filter::from_str("_geoBoundingBox((-90.0000001, 150), (30, 10))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([-90.0000001, 150], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(
error.to_string().starts_with(
@ -831,7 +831,7 @@ mod tests {
// geoboundingbox top left coord have a bad latitude
let filter =
Filter::from_str("_geoBoundingBox((90.0000001, 150), (30, 10))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([90.0000001, 150], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(
error.to_string().starts_with(
@ -843,7 +843,7 @@ mod tests {
// geoboundingbox bottom right coord have a bad latitude
let filter =
Filter::from_str("_geoBoundingBox((30, 10), (-90.0000001, 150))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([30, 10], [-90.0000001, 150])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains(
"Bad latitude `-90.0000001`. Latitude must be contained between -90 and 90 degrees."
@ -851,7 +851,7 @@ mod tests {
// geoboundingbox bottom right coord have a bad latitude
let filter =
Filter::from_str("_geoBoundingBox((30, 10), (90.0000001, 150))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([30, 10], [90.0000001, 150])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains(
"Bad latitude `90.0000001`. Latitude must be contained between -90 and 90 degrees."
@ -859,7 +859,7 @@ mod tests {
// geoboundingbox top left coord have a bad longitude
let filter =
Filter::from_str("_geoBoundingBox((-10, 180.000001), (30, 10))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([-10, 180.000001], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains(
"Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees."
@ -867,7 +867,7 @@ mod tests {
// geoboundingbox top left coord have a bad longitude
let filter =
Filter::from_str("_geoBoundingBox((-10, -180.000001), (30, 10))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([-10, -180.000001], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains(
"Bad longitude `-180.000001`. Longitude must be contained between -180 and 180 degrees."
@ -875,7 +875,7 @@ mod tests {
// geoboundingbox bottom right coord have a bad longitude
let filter =
Filter::from_str("_geoBoundingBox((30, 10), (-10, -180.000001))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([30, 10], [-10, -180.000001])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains(
"Bad longitude `-180.000001`. Longitude must be contained between -180 and 180 degrees."
@ -883,7 +883,7 @@ mod tests {
// geoboundingbox bottom right coord have a bad longitude
let filter =
Filter::from_str("_geoBoundingBox((30, 10), (-10, 180.000001))").unwrap().unwrap();
Filter::from_str("_geoBoundingBox([30, 10], [-10, 180.000001])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains(
"Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees."