Fix some errors

This commit is contained in:
many 2021-10-26 19:36:48 +02:00
parent 61c15b69fb
commit 7464720426
No known key found for this signature in database
GPG key ID: 2CEF23B75189EACA
27 changed files with 347 additions and 234 deletions

View file

@ -99,7 +99,7 @@ impl Index<'_> {
pub async fn wait_update_id(&self, update_id: u64) -> Value {
// try 10 times to get status, or panic to not wait forever
let url = format!("/indexes/{}/updates/{}", self.uid, update_id);
for _ in 0..10 {
for _ in 0..20 {
let (response, status_code) = self.service.get(&url).await;
assert_eq!(status_code, 200, "response: {}", response);

View file

@ -80,7 +80,7 @@ async fn error_add_documents_test_bad_content_types() {
assert_eq!(
response["message"],
json!(
r#"The Content-Type "text/plain" is invalid. Accepted values for the Content-Type header are: "application/json", "application/x-ndjson", "text/csv""#
r#"The Content-Type `text/plain` is invalid. Accepted values for the Content-Type header are: `application/json`, `application/x-ndjson`, `text/csv`"#
)
);
assert_eq!(response["code"], "invalid_content_type");
@ -104,7 +104,7 @@ async fn error_add_documents_test_bad_content_types() {
assert_eq!(
response["message"],
json!(
r#"The Content-Type "text/plain" is invalid. Accepted values for the Content-Type header are: "application/json", "application/x-ndjson", "text/csv""#
r#"The Content-Type `text/plain` is invalid. Accepted values for the Content-Type header are: `application/json`, `application/x-ndjson`, `text/csv`"#
)
);
assert_eq!(response["code"], "invalid_content_type");
@ -145,7 +145,7 @@ async fn error_add_documents_test_no_content_type() {
assert_eq!(
response["message"],
json!(
r#"A Content-Type header is missing. Accepted values for the Content-Type header are: "application/json", "application/x-ndjson", "text/csv""#
r#"A Content-Type header is missing. Accepted values for the Content-Type header are: `application/json`, `application/x-ndjson`, `text/csv`"#
)
);
assert_eq!(response["code"], "missing_content_type");
@ -168,7 +168,7 @@ async fn error_add_documents_test_no_content_type() {
assert_eq!(
response["message"],
json!(
r#"A Content-Type header is missing. Accepted values for the Content-Type header are: "application/json", "application/x-ndjson", "text/csv""#
r#"A Content-Type header is missing. Accepted values for the Content-Type header are: `application/json`, `application/x-ndjson`, `text/csv`"#
)
);
assert_eq!(response["code"], "missing_content_type");
@ -204,7 +204,7 @@ async fn error_add_malformed_csv_documents() {
assert_eq!(
response["message"],
json!(
r#"The csv payload provided is malformed. CSV error: record 1 (line: 2, byte: 12): found record with 3 fields, but the previous record has 2 fields."#
r#"The `csv` payload provided is malformed. `CSV error: record 1 (line: 2, byte: 12): found record with 3 fields, but the previous record has 2 fields`."#
)
);
assert_eq!(response["code"], json!("malformed_payload"));
@ -228,7 +228,7 @@ async fn error_add_malformed_csv_documents() {
assert_eq!(
response["message"],
json!(
r#"The csv payload provided is malformed. CSV error: record 1 (line: 2, byte: 12): found record with 3 fields, but the previous record has 2 fields."#
r#"The `csv` payload provided is malformed. `CSV error: record 1 (line: 2, byte: 12): found record with 3 fields, but the previous record has 2 fields`."#
)
);
assert_eq!(response["code"], json!("malformed_payload"));
@ -264,7 +264,7 @@ async fn error_add_malformed_json_documents() {
assert_eq!(
response["message"],
json!(
r#"The json payload provided is malformed. key must be a string at line 1 column 14."#
r#"The `json` payload provided is malformed. `Couldn't serialize document value: key must be a string at line 1 column 14`."#
)
);
assert_eq!(response["code"], json!("malformed_payload"));
@ -288,7 +288,7 @@ async fn error_add_malformed_json_documents() {
assert_eq!(
response["message"],
json!(
r#"The json payload provided is malformed. key must be a string at line 1 column 14."#
r#"The `json` payload provided is malformed. `Couldn't serialize document value: key must be a string at line 1 column 14`."#
)
);
assert_eq!(response["code"], json!("malformed_payload"));
@ -324,7 +324,7 @@ async fn error_add_malformed_ndjson_documents() {
assert_eq!(
response["message"],
json!(
r#"The ndjson payload provided is malformed. key must be a string at line 2 column 2."#
r#"The `ndjson` payload provided is malformed. `Couldn't serialize document value: key must be a string at line 1 column 2`."#
)
);
assert_eq!(response["code"], json!("malformed_payload"));
@ -348,7 +348,7 @@ async fn error_add_malformed_ndjson_documents() {
assert_eq!(
response["message"],
json!(
r#"The ndjson payload provided is malformed. key must be a string at line 2 column 2."#
r#"The `ndjson` payload provided is malformed. `Couldn't serialize document value: key must be a string at line 1 column 2`."#
)
);
assert_eq!(response["code"], json!("malformed_payload"));
@ -359,6 +359,162 @@ async fn error_add_malformed_ndjson_documents() {
);
}
#[actix_rt::test]
async fn error_add_missing_payload_csv_documents() {
let document = "";
let server = Server::new().await;
let app = test::init_service(create_app!(
&server.service.meilisearch,
true,
&server.service.options
))
.await;
// post
let req = test::TestRequest::post()
.uri("/indexes/dog/documents")
.set_payload(document.to_string())
.insert_header(("content-type", "text/csv"))
.to_request();
let res = test::call_service(&app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 400);
assert_eq!(response["message"], json!(r#"A csv payload is missing."#));
assert_eq!(response["code"], json!("missing_payload"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
json!("https://docs.meilisearch.com/errors#missing_payload")
);
// put
let req = test::TestRequest::put()
.uri("/indexes/dog/documents")
.set_payload(document.to_string())
.insert_header(("content-type", "text/csv"))
.to_request();
let res = test::call_service(&app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 400);
assert_eq!(response["message"], json!(r#"A csv payload is missing."#));
assert_eq!(response["code"], json!("missing_payload"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
json!("https://docs.meilisearch.com/errors#missing_payload")
);
}
#[actix_rt::test]
async fn error_add_missing_payload_json_documents() {
let document = "";
let server = Server::new().await;
let app = test::init_service(create_app!(
&server.service.meilisearch,
true,
&server.service.options
))
.await;
// post
let req = test::TestRequest::post()
.uri("/indexes/dog/documents")
.set_payload(document.to_string())
.insert_header(("content-type", "application/json"))
.to_request();
let res = test::call_service(&app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 400);
assert_eq!(response["message"], json!(r#"A json payload is missing."#));
assert_eq!(response["code"], json!("missing_payload"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
json!("https://docs.meilisearch.com/errors#missing_payload")
);
// put
let req = test::TestRequest::put()
.uri("/indexes/dog/documents")
.set_payload(document.to_string())
.insert_header(("content-type", "application/json"))
.to_request();
let res = test::call_service(&app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 400);
assert_eq!(response["message"], json!(r#"A json payload is missing."#));
assert_eq!(response["code"], json!("missing_payload"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
json!("https://docs.meilisearch.com/errors#missing_payload")
);
}
#[actix_rt::test]
async fn error_add_missing_payload_ndjson_documents() {
let document = "";
let server = Server::new().await;
let app = test::init_service(create_app!(
&server.service.meilisearch,
true,
&server.service.options
))
.await;
// post
let req = test::TestRequest::post()
.uri("/indexes/dog/documents")
.set_payload(document.to_string())
.insert_header(("content-type", "application/x-ndjson"))
.to_request();
let res = test::call_service(&app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 400);
assert_eq!(
response["message"],
json!(r#"A ndjson payload is missing."#)
);
assert_eq!(response["code"], json!("missing_payload"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
json!("https://docs.meilisearch.com/errors#missing_payload")
);
// put
let req = test::TestRequest::put()
.uri("/indexes/dog/documents")
.set_payload(document.to_string())
.insert_header(("content-type", "application/x-ndjson"))
.to_request();
let res = test::call_service(&app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 400);
assert_eq!(
response["message"],
json!(r#"A ndjson payload is missing."#)
);
assert_eq!(response["code"], json!("missing_payload"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
json!("https://docs.meilisearch.com/errors#missing_payload")
);
}
#[actix_rt::test]
async fn add_documents_no_index_creation() {
let server = Server::new().await;
@ -411,7 +567,7 @@ async fn error_document_add_create_index_bad_uid() {
let (response, code) = index.add_documents(json!([]), None).await;
let expected_response = json!({
"message": "883 fj! is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
"message": "`883 fj!` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
"code": "invalid_index_uid",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_index_uid"
@ -428,7 +584,7 @@ async fn error_document_update_create_index_bad_uid() {
let (response, code) = index.update_documents(json!([]), None).await;
let expected_response = json!({
"message": "883 fj! is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
"message": "`883 fj!` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
"code": "invalid_index_uid",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_index_uid"
@ -646,13 +802,13 @@ async fn error_add_documents_bad_document_id() {
index.wait_update_id(0).await;
let (response, code) = index.get_update(0).await;
assert_eq!(code, 200);
assert_eq!(response["status"], "failed");
assert_eq!(response["message"], "Document identifier foo & bar is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_).");
assert_eq!(response["code"], "invalid_document_id");
assert_eq!(response["type"], "invalid_request");
assert_eq!(response["status"], json!("failed"));
assert_eq!(response["message"], json!("Document identifier `foo & bar` is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_)."));
assert_eq!(response["code"], json!("invalid_document_id"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
"https://docs.meilisearch.com/errors#invalid_document_id"
json!("https://docs.meilisearch.com/errors#invalid_document_id")
);
}
@ -671,13 +827,13 @@ async fn error_update_documents_bad_document_id() {
index.wait_update_id(0).await;
let (response, code) = index.get_update(0).await;
assert_eq!(code, 200);
assert_eq!(response["status"], "failed");
assert_eq!(response["message"], "Document identifier foo & bar is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_).");
assert_eq!(response["code"], "invalid_document_id");
assert_eq!(response["type"], "invalid_request");
assert_eq!(response["status"], json!("failed"));
assert_eq!(response["message"], json!("Document identifier `foo & bar` is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_)."));
assert_eq!(response["code"], json!("invalid_document_id"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
"https://docs.meilisearch.com/errors#invalid_document_id"
json!("https://docs.meilisearch.com/errors#invalid_document_id")
);
}
@ -699,13 +855,13 @@ async fn error_add_documents_missing_document_id() {
assert_eq!(response["status"], "failed");
assert_eq!(
response["message"],
r#"Document doesn't have a docid attribute: {"id":"11","content":"foobar"}."#
json!(r#"Document doesn't have a `docid` attribute: `{"id":"11","content":"foobar"}`."#)
);
assert_eq!(response["code"], "missing_document_id");
assert_eq!(response["type"], "invalid_request");
assert_eq!(response["code"], json!("missing_document_id"));
assert_eq!(response["type"], json!("invalid_request"));
assert_eq!(
response["link"],
"https://docs.meilisearch.com/errors#missing_document_id"
json!("https://docs.meilisearch.com/errors#missing_document_id")
);
}
@ -727,7 +883,7 @@ async fn error_update_documents_missing_document_id() {
assert_eq!(response["status"], "failed");
assert_eq!(
response["message"],
r#"Document doesn't have a docid attribute: {"id":"11","content":"foobar"}."#
r#"Document doesn't have a `docid` attribute: `{"id":"11","content":"foobar"}`."#
);
assert_eq!(response["code"], "missing_document_id");
assert_eq!(response["type"], "invalid_request");
@ -737,109 +893,41 @@ async fn error_update_documents_missing_document_id() {
);
}
#[actix_rt::test]
async fn error_add_documents_with_primary_key_and_primary_key_already_exists() {
let server = Server::new().await;
let index = server.index("test");
// #[actix_rt::test]
// async fn error_document_field_limit_reached() {
// let server = Server::new().await;
// let index = server.index("test");
index.create(Some("primary")).await;
let documents = json!([
{
"id": 1,
"content": "foo",
}
]);
// index.create(Some("id")).await;
let (_response, code) = index.add_documents(documents, Some("id")).await;
assert_eq!(code, 202);
// let mut big_object = std::collections::HashMap::new();
// big_object.insert("id".to_owned(), "wow");
// for i in 0..65535 {
// let key = i.to_string();
// big_object.insert(key, "I am a text!");
// }
index.wait_update_id(0).await;
// let documents = json!([big_object]);
let (response, code) = index.get_update(0).await;
assert_eq!(code, 200);
assert_eq!(response["status"], "failed");
assert_eq!(response["message"], "Index test already has a primary key.");
assert_eq!(response["code"], "index_primary_key_already_exists");
assert_eq!(response["type"], "invalid_request");
assert_eq!(
response["link"],
"https://docs.meilisearch.com/errors#index_primary_key_already_exists"
);
// let (_response, code) = index.update_documents(documents, Some("id")).await;
// assert_eq!(code, 202);
let (response, code) = index.get().await;
assert_eq!(code, 200);
assert_eq!(response["primaryKey"], "primary");
}
#[actix_rt::test]
async fn error_update_documents_with_primary_key_and_primary_key_already_exists() {
let server = Server::new().await;
let index = server.index("test");
index.create(Some("primary")).await;
let documents = json!([
{
"id": 1,
"content": "foo",
}
]);
let (_response, code) = index.update_documents(documents, Some("id")).await;
assert_eq!(code, 202);
index.wait_update_id(0).await;
let (response, code) = index.get_update(0).await;
assert_eq!(code, 200);
// Documents without a primary key are not accepted.
assert_eq!(response["status"], "failed");
assert_eq!(response["message"], "Index test already has a primary key.");
assert_eq!(response["code"], "index_primary_key_already_exists");
assert_eq!(response["type"], "invalid_request");
assert_eq!(
response["link"],
"https://docs.meilisearch.com/errors#index_primary_key_already_exists"
);
let (response, code) = index.get().await;
assert_eq!(code, 200);
assert_eq!(response["primaryKey"], "primary");
}
#[actix_rt::test]
async fn error_document_field_limit_reached() {
let server = Server::new().await;
let index = server.index("test");
index.create(Some("id")).await;
let mut big_object = std::collections::HashMap::new();
big_object.insert("id".to_owned(), "wow");
for i in 0..65535 {
let key = i.to_string();
big_object.insert(key, "I am a text!");
}
let documents = json!([big_object]);
let (_response, code) = index.update_documents(documents, Some("id")).await;
assert_eq!(code, 202);
index.wait_update_id(0).await;
let (response, code) = index.get_update(0).await;
assert_eq!(code, 200);
// Documents without a primary key are not accepted.
assert_eq!(response["status"], "failed");
assert_eq!(
response["message"],
"A document cannot contain more than 65,535 fields."
);
assert_eq!(response["code"], "document_fields_limit_reached");
assert_eq!(response["type"], "invalid_request");
assert_eq!(
response["link"],
"https://docs.meilisearch.com/errors#document_fields_limit_reached"
);
}
// index.wait_update_id(0).await;
// let (response, code) = index.get_update(0).await;
// assert_eq!(code, 200);
// // Documents without a primary key are not accepted.
// assert_eq!(response["status"], "failed");
// assert_eq!(
// response["message"],
// "A document cannot contain more than 65,535 fields."
// );
// assert_eq!(response["code"], "document_fields_limit_reached");
// assert_eq!(response["type"], "invalid_request");
// assert_eq!(
// response["link"],
// "https://docs.meilisearch.com/errors#document_fields_limit_reached"
// );
// }
#[actix_rt::test]
async fn error_add_documents_invalid_geo_field() {
@ -885,7 +973,7 @@ async fn error_add_documents_payload_size() {
let (response, code) = index.add_documents(documents, None).await;
let expected_response = json!({
"message": "The payload cannot exceed 10MB.",
"message": "The provided payload reached the size limit.",
"code": "payload_too_large",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#payload_too_large"

View file

@ -87,7 +87,7 @@ async fn error_delete_batch_unexisting_index() {
let server = Server::new().await;
let (response, code) = server.index("test").delete_batch(vec![]).await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"

View file

@ -20,7 +20,7 @@ async fn error_get_unexisting_document() {
let (response, code) = index.get_document(1, None).await;
let expected_response = json!({
"message": "Document 1 not found.",
"message": "Document `1` not found.",
"code": "document_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#document_not_found"
@ -64,7 +64,7 @@ async fn error_get_unexisting_index_all_documents() {
.await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"

View file

@ -78,7 +78,7 @@ async fn error_create_existing_index() {
let (response, code) = index.create(Some("primary")).await;
let expected_response = json!({
"message": "Index primary already exists.",
"message": "Index `test` already exists.",
"code": "index_already_exists",
"type": "invalid_request",
"link":"https://docs.meilisearch.com/errors#index_already_exists"
@ -95,7 +95,7 @@ async fn error_create_with_invalid_index_uid() {
let (response, code) = index.create(None).await;
let expected_response = json!({
"message": "test test#! is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
"message": "`test test#!` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
"code": "invalid_index_uid",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_index_uid"

View file

@ -24,7 +24,7 @@ async fn error_delete_unexisting_index() {
let (response, code) = index.delete().await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"

View file

@ -30,7 +30,7 @@ async fn error_get_unexisting_index() {
let (response, code) = index.get().await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"

View file

@ -53,7 +53,7 @@ async fn error_get_stats_unexisting_index() {
let (response, code) = server.index("test").stats().await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"

View file

@ -44,14 +44,23 @@ async fn update_nothing() {
async fn error_update_existing_primary_key() {
let server = Server::new().await;
let index = server.index("test");
let (_response, code) = index.create(Some("primary")).await;
let (_response, code) = index.create(Some("id")).await;
assert_eq!(code, 201);
let (response, code) = index.update(Some("primary2")).await;
let documents = json!([
{
"id": "11",
"content": "foobar"
}
]);
index.add_documents(documents, None).await;
index.wait_update_id(0).await;
let (response, code) = index.update(Some("primary")).await;
let expected_response = json!({
"message": "Index test already has a primary key.",
"message": "Index already has a primary key: `id`.",
"code": "index_primary_key_already_exists",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_primary_key_already_exists"
@ -67,7 +76,7 @@ async fn error_update_unexisting_index() {
let (response, code) = server.index("test").update(None).await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"

View file

@ -8,10 +8,17 @@ async fn search_unexisting_index() {
let server = Server::new().await;
let index = server.index("test");
let expected_response = json!({
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"
});
index
.search(json!({"q": "hello"}), |response, code| {
assert_eq!(code, 404, "{}", response);
assert_eq!(response["errorCode"], "index_not_found");
assert_eq!(code, 404);
assert_eq!(response, expected_response);
})
.await;
}
@ -24,7 +31,7 @@ async fn search_unexisting_parameter() {
index
.search(json!({"marin": "hello"}), |response, code| {
assert_eq!(code, 400, "{}", response);
assert_eq!(response["errorCode"], "bad_request");
assert_eq!(response["code"], "bad_request");
})
.await;
}
@ -43,13 +50,13 @@ async fn filter_invalid_syntax_object() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "Invalid syntax for the filter parameter: :syntaxErrorHelper:REPLACE_ME.",
"message": "Invalid syntax for the filter parameter: ` --> 1:7\n |\n1 | title & Glass\n | ^---\n |\n = expected word`.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
});
index
.search(json!({"filter": {"title": "Glass"}}), |response, code| {
.search(json!({"filter": "title & Glass"}), |response, code| {
assert_eq!(response, expected_response);
assert_eq!(code, 400);
})
@ -70,19 +77,16 @@ async fn filter_invalid_syntax_array() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "Invalid syntax for the filter parameter: :syntaxErrorHelper:REPLACE_ME.",
"message": "Invalid syntax for the filter parameter: ` --> 1:7\n |\n1 | title & Glass\n | ^---\n |\n = expected word`.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
});
index
.search(
json!({"filter": [[["title = Glass"]]]}),
|response, code| {
assert_eq!(response, expected_response);
assert_eq!(code, 400);
},
)
.search(json!({"filter": [["title & Glass"]]}), |response, code| {
assert_eq!(response, expected_response);
assert_eq!(code, 400);
})
.await;
}
@ -100,7 +104,7 @@ async fn filter_invalid_syntax_string() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "Invalid syntax for the filter parameter: :syntaxErrorHelper:REPLACE_ME.",
"message": "Invalid syntax for the filter parameter: ` --> 1:15\n |\n1 | title = Glass XOR title = Glass\n | ^---\n |\n = expected EOI, and, or or`.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
@ -130,7 +134,7 @@ async fn filter_invalid_attribute_array() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "Attribute many is not filterable. Available filterable attributes are: title.",
"message": "Attribute `many` is not filterable. Available filterable attributes are: `title`.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
@ -157,7 +161,7 @@ async fn filter_invalid_attribute_string() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "Attribute many is not filterable. Available filterable attributes are: title.",
"message": "Attribute `many` is not filterable. Available filterable attributes are: `title`.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
@ -184,7 +188,7 @@ async fn filter_reserved_geo_attribute_array() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "_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.",
"message": "`_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.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
@ -211,7 +215,7 @@ async fn filter_reserved_geo_attribute_string() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "_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.",
"message": "`_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.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
@ -238,7 +242,7 @@ async fn filter_reserved_attribute_array() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "_geoDistance is a reserved keyword and thus can't be used as a filter expression.",
"message": "`_geoDistance` is a reserved keyword and thus can't be used as a filter expression.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
@ -268,7 +272,7 @@ async fn filter_reserved_attribute_string() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "_geoDistance is a reserved keyword and thus can't be used as a filter expression.",
"message": "`_geoDistance` is a reserved keyword and thus can't be used as a filter expression.",
"code": "invalid_filter",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_filter"
@ -298,7 +302,7 @@ async fn sort_geo_reserved_attribute() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "_geo is a reserved keyword and thus can't be used as a filter expression. Use the _geoPoint(latitude, longitude) built-in rule to sort on _geo field coordinates.",
"message": "`_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.",
"code": "invalid_sort",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_sort"
@ -330,7 +334,7 @@ async fn sort_reserved_attribute() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "_geoDistance is a reserved keyword and thus can't be used as a filter expression.",
"message": "`_geoDistance` is a reserved keyword and thus can't be used as a sort expression.",
"code": "invalid_sort",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_sort"
@ -362,7 +366,7 @@ async fn sort_unsortable_attribute() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "Attribute title is not sortable. Available sortable attributes are: id.",
"message": "Attribute `title` is not sortable. Available sortable attributes are: `id`.",
"code": "invalid_sort",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_sort"
@ -394,7 +398,7 @@ async fn sort_invalid_syntax() {
index.wait_update_id(1).await;
let expected_response = json!({
"message": "Invalid syntax for the sort parameter: :syntaxErrorHelper:REPLACE_ME.",
"message": "Invalid syntax for the sort parameter: expected expression ending by `:asc` or `:desc`, found `title`.",
"code": "invalid_sort",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_sort"
@ -419,7 +423,7 @@ async fn sort_unset_ranking_rule() {
index
.update_settings(
json!({"sortableAttributes": ["id"], "rankingRules": ["proximity", "exactness"]}),
json!({"sortableAttributes": ["title"], "rankingRules": ["proximity", "exactness"]}),
)
.await;
@ -436,7 +440,7 @@ async fn sort_unset_ranking_rule() {
index
.search(
json!({
"sort": ["title"]
"sort": ["title:asc"]
}),
|response, code| {
assert_eq!(response, expected_response);

View file

@ -7,7 +7,7 @@ async fn error_get_update_unexisting_index() {
let (response, code) = server.index("test").get_update(0).await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"
@ -25,7 +25,7 @@ async fn error_get_unexisting_update_status() {
let (response, code) = index.get_update(0).await;
let expected_response = json!({
"message": "Task 0 not found.",
"message": "Task `0` not found.",
"code": "task_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#task_not_found"
@ -60,7 +60,7 @@ async fn error_list_updates_unexisting_index() {
let (response, code) = server.index("test").list_updates().await;
let expected_response = json!({
"message": "Index test not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"