mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 21:20:24 +01:00
Lower error check, already check in meilisearch
This commit is contained in:
parent
3599df77f0
commit
2be755ce75
@ -318,50 +318,4 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sort_error_message() {
|
||||
let errors = [
|
||||
(
|
||||
AscDescError::InvalidSyntax { name: S("truc:machin") },
|
||||
S("invalid syntax for the sort parameter `truc:machin`."),
|
||||
),
|
||||
(
|
||||
AscDescError::InvalidSyntax { name: S("hello:world") },
|
||||
S("invalid syntax for the sort parameter `hello:world`."),
|
||||
),
|
||||
(
|
||||
AscDescError::ReservedKeyword { name: S("_geo") },
|
||||
S("`_geo` is a reserved keyword and thus can't be used as a sort expression. Use the `_geoPoint(latitude, longitude)` built-in rule to sort on `_geo` field coordinates."),
|
||||
),
|
||||
(
|
||||
AscDescError::ReservedKeyword { name: S("_geoDistance") },
|
||||
S("_geoDistance is a reserved keyword and thus can't be used as a sort expression.")
|
||||
),
|
||||
(
|
||||
AscDescError::ReservedKeyword { name: S("_geoRadius(12, 13)") },
|
||||
S("`_geoRadius` is a reserved keyword and thus can't be used as a sort expression. Use the `_geoPoint(latitude, longitude)` built-in rule to sort on `_geo` field coordinates."),
|
||||
),
|
||||
(
|
||||
AscDescError::InvalidLatitude,
|
||||
S("Latitude must be contained between -90 and 90 degrees."),
|
||||
),
|
||||
(
|
||||
AscDescError::InvalidLongitude,
|
||||
S("Longitude must be contained between -180 and 180 degrees."),
|
||||
),
|
||||
];
|
||||
|
||||
for (asc_desc_error, expected_message) in errors {
|
||||
let sort_error = SortError::from(asc_desc_error);
|
||||
assert_eq!(
|
||||
sort_error.to_string(),
|
||||
expected_message,
|
||||
"was expecting {} for the error {:?} but instead got {}",
|
||||
expected_message,
|
||||
sort_error,
|
||||
sort_error.to_string()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -755,39 +755,13 @@ mod tests {
|
||||
let index = Index::new(options, &path).unwrap();
|
||||
let rtxn = index.read_txn().unwrap();
|
||||
|
||||
let error = FilterCondition::from_str(&rtxn, &index, "_geo = 12").unwrap_err();
|
||||
assert!(error
|
||||
.to_string()
|
||||
.contains("`_geo` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` built-in rule to filter on `_geo` field coordinates."),
|
||||
"{}",
|
||||
error.to_string()
|
||||
);
|
||||
assert!(FilterCondition::from_str(&rtxn, &index, "_geo = 12").is_err());
|
||||
|
||||
let error =
|
||||
FilterCondition::from_str(&rtxn, &index, r#"_geoDistance <= 1000"#).unwrap_err();
|
||||
assert!(error
|
||||
.to_string()
|
||||
.contains("`_geoDistance` is a reserved keyword and thus can't be used as a filter expression."),
|
||||
"{}",
|
||||
error.to_string()
|
||||
);
|
||||
assert!(FilterCondition::from_str(&rtxn, &index, r#"_geoDistance <= 1000"#).is_err());
|
||||
|
||||
let error = FilterCondition::from_str(&rtxn, &index, r#"_geoPoint > 5"#).unwrap_err();
|
||||
assert!(error
|
||||
.to_string()
|
||||
.contains("`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` built-in rule to filter on `_geo` field coordinates."),
|
||||
"{}",
|
||||
error.to_string()
|
||||
);
|
||||
assert!(FilterCondition::from_str(&rtxn, &index, r#"_geoPoint > 5"#).is_err());
|
||||
|
||||
let error =
|
||||
FilterCondition::from_str(&rtxn, &index, r#"_geoPoint(12, 16) > 5"#).unwrap_err();
|
||||
assert!(error
|
||||
.to_string()
|
||||
.contains("`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` built-in rule to filter on `_geo` field coordinates."),
|
||||
"{}",
|
||||
error.to_string()
|
||||
);
|
||||
assert!(FilterCondition::from_str(&rtxn, &index, r#"_geoPoint(12, 16) > 5"#).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -804,15 +778,6 @@ mod tests {
|
||||
builder.execute(|_, _| ()).unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
|
||||
let rtxn = index.read_txn().unwrap();
|
||||
// _geo is not filterable
|
||||
let result = FilterCondition::from_str(&rtxn, &index, "_geoRadius(12, 12, 10)");
|
||||
assert!(result.is_err());
|
||||
let error = result.unwrap_err();
|
||||
assert!(error
|
||||
.to_string()
|
||||
.contains("attribute `_geo` is not filterable, available filterable attributes are:"),);
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut builder = Settings::new(&mut wtxn, &index, 0);
|
||||
builder.set_filterable_fields(hashset! { S("_geo"), S("price") });
|
||||
|
Loading…
x
Reference in New Issue
Block a user