Format fixes after running: cargo +nightly fmt

This commit is contained in:
Mahmoud Rawas 2025-01-07 11:16:37 +11:00
parent d7cb319217
commit 98e3ecb86b
21 changed files with 208 additions and 189 deletions

View File

@ -1,6 +1,7 @@
use crate::option::Opt;
use clap::Parser; use clap::Parser;
use crate::option::Opt;
#[test] #[test]
fn test_valid_opt() { fn test_valid_opt() {
assert!(Opt::try_parse_from(Some("")).is_ok()); assert!(Opt::try_parse_from(Some("")).is_ok());

View File

@ -146,7 +146,7 @@ macro_rules! compute_forbidden_search {
server.use_admin_key("MASTER_KEY").await; server.use_admin_key("MASTER_KEY").await;
let index = server.index("sales"); let index = server.index("sales");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
drop(index); drop(index);

View File

@ -11,7 +11,7 @@ use crate::json;
async fn error_get_unexisting_batch_status() { async fn error_get_unexisting_batch_status() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_coder) = index.create(None).await; let (task, _coder) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_batch(1).await; let (response, code) = index.get_batch(1).await;
@ -40,7 +40,7 @@ async fn get_batch_status() {
async fn list_batches() { async fn list_batches() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -142,9 +142,9 @@ async fn list_batches_with_star_filters() {
async fn list_batches_status_filtered() { async fn list_batches_status_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = index let (task, _status_code) = index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
@ -168,7 +168,7 @@ async fn list_batches_status_filtered() {
async fn list_batches_type_filtered() { async fn list_batches_type_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -188,7 +188,7 @@ async fn list_batches_type_filtered() {
async fn list_batches_invalid_canceled_by_filter() { async fn list_batches_invalid_canceled_by_filter() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -203,7 +203,7 @@ async fn list_batches_invalid_canceled_by_filter() {
async fn list_batches_status_and_type_filtered() { async fn list_batches_status_and_type_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -277,7 +277,8 @@ async fn list_batch_filter_error() {
async fn test_summarized_document_addition_or_update() { async fn test_summarized_document_addition_or_update() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), None).await; let (task, _status_code) =
index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(0).await; let (batch, _) = index.get_batch(0).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -308,7 +309,8 @@ async fn test_summarized_document_addition_or_update() {
} }
"#); "#);
let (task,_status_code) = index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), Some("id")).await; let (task, _status_code) =
index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), Some("id")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(1).await; let (batch, _) = index.get_batch(1).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -344,7 +346,7 @@ async fn test_summarized_document_addition_or_update() {
async fn test_summarized_delete_documents_by_batch() { async fn test_summarized_delete_documents_by_batch() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.delete_batch(vec![1, 2, 3]).await; let (task, _status_code) = index.delete_batch(vec![1, 2, 3]).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(0).await; let (batch, _) = index.get_batch(0).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -376,7 +378,7 @@ async fn test_summarized_delete_documents_by_batch() {
"#); "#);
index.create(None).await; index.create(None).await;
let (task,_status_code) = index.delete_batch(vec![42]).await; let (task, _status_code) = index.delete_batch(vec![42]).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(2).await; let (batch, _) = index.get_batch(2).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -413,7 +415,8 @@ async fn test_summarized_delete_documents_by_filter() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; let (task, _status_code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(0).await; let (batch, _) = index.get_batch(0).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -446,7 +449,8 @@ async fn test_summarized_delete_documents_by_filter() {
"#); "#);
index.create(None).await; index.create(None).await;
let (task,_status_code) = index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; let (task, _status_code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(2).await; let (batch, _) = index.get_batch(2).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -479,7 +483,8 @@ async fn test_summarized_delete_documents_by_filter() {
"#); "#);
index.update_settings(json!({ "filterableAttributes": ["doggo"] })).await; index.update_settings(json!({ "filterableAttributes": ["doggo"] })).await;
let (task,_status_code) = index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; let (task, _status_code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(4).await; let (batch, _) = index.get_batch(4).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -516,7 +521,7 @@ async fn test_summarized_delete_documents_by_filter() {
async fn test_summarized_delete_document_by_id() { async fn test_summarized_delete_document_by_id() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.delete_document(1).await; let (task, _status_code) = index.delete_document(1).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(0).await; let (batch, _) = index.get_batch(0).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -548,7 +553,7 @@ async fn test_summarized_delete_document_by_id() {
"#); "#);
index.create(None).await; index.create(None).await;
let (task,_status_code) = index.delete_document(42).await; let (task, _status_code) = index.delete_document(42).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(2).await; let (batch, _) = index.get_batch(2).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -641,7 +646,7 @@ async fn test_summarized_settings_update() {
async fn test_summarized_index_creation() { async fn test_summarized_index_creation() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(0).await; let (batch, _) = index.get_batch(0).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -669,7 +674,7 @@ async fn test_summarized_index_creation() {
} }
"#); "#);
let (task,_status_code) = index.create(Some("doggos")).await; let (task, _status_code) = index.create(Some("doggos")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(1).await; let (batch, _) = index.get_batch(1).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -814,7 +819,7 @@ async fn test_summarized_index_update() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
// If the index doesn't exist yet, we should get errors with or without the primary key. // If the index doesn't exist yet, we should get errors with or without the primary key.
let (task,_status_code) = index.update(None).await; let (task, _status_code) = index.update(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(0).await; let (batch, _) = index.get_batch(0).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -842,7 +847,7 @@ async fn test_summarized_index_update() {
} }
"#); "#);
let (task,_status_code) = index.update(Some("bones")).await; let (task, _status_code) = index.update(Some("bones")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(1).await; let (batch, _) = index.get_batch(1).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -875,7 +880,7 @@ async fn test_summarized_index_update() {
// And run the same two tests once the index do exists. // And run the same two tests once the index do exists.
index.create(None).await; index.create(None).await;
let (task,_status_code) = index.update(None).await; let (task, _status_code) = index.update(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(3).await; let (batch, _) = index.get_batch(3).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -903,7 +908,7 @@ async fn test_summarized_index_update() {
} }
"#); "#);
let (task,_status_code) = index.update(Some("bones")).await; let (task, _status_code) = index.update(Some("bones")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(4).await; let (batch, _) = index.get_batch(4).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -937,7 +942,7 @@ async fn test_summarized_index_update() {
#[actix_web::test] #[actix_web::test]
async fn test_summarized_index_swap() { async fn test_summarized_index_swap() {
let server = Server::new().await; let server = Server::new().await;
let (task,_status_code) = server let (task, _status_code) = server
.index_swap(json!([ .index_swap(json!([
{ "indexes": ["doggos", "cattos"] } { "indexes": ["doggos", "cattos"] }
])) ]))
@ -977,7 +982,7 @@ async fn test_summarized_index_swap() {
"#); "#);
server.index("doggos").create(None).await; server.index("doggos").create(None).await;
let (task,_status_code) = server.index("cattos").create(None).await; let (task, _status_code) = server.index("cattos").create(None).await;
server server
.index_swap(json!([ .index_swap(json!([
{ "indexes": ["doggos", "cattos"] } { "indexes": ["doggos", "cattos"] }
@ -1023,9 +1028,9 @@ async fn test_summarized_batch_cancelation() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("doggos"); let index = server.index("doggos");
// to avoid being flaky we're only going to cancel an already finished batch :( // to avoid being flaky we're only going to cancel an already finished batch :(
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = server.cancel_tasks("uids=0").await; let (task, _status_code) = server.cancel_tasks("uids=0").await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
//TODO: create a get_batch function interface that accepts u64, and remove the following cast. //TODO: create a get_batch function interface that accepts u64, and remove the following cast.
let (batch, _) = index.get_batch(task.uid().to_u32().unwrap()).await; let (batch, _) = index.get_batch(task.uid().to_u32().unwrap()).await;
@ -1062,9 +1067,9 @@ async fn test_summarized_batch_deletion() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("doggos"); let index = server.index("doggos");
// to avoid being flaky we're only going to delete an already finished batch :( // to avoid being flaky we're only going to delete an already finished batch :(
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = server.delete_tasks("uids=0").await; let (task, _status_code) = server.delete_tasks("uids=0").await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (batch, _) = index.get_batch(1).await; let (batch, _) = index.get_batch(1).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,
@ -1098,7 +1103,7 @@ async fn test_summarized_batch_deletion() {
#[actix_web::test] #[actix_web::test]
async fn test_summarized_dump_creation() { async fn test_summarized_dump_creation() {
let server = Server::new().await; let server = Server::new().await;
let (task,_status_code) = server.create_dump().await; let (task, _status_code) = server.create_dump().await;
server.wait_task(task.uid()).await; server.wait_task(task.uid()).await;
let (batch, _) = server.get_batch(0).await; let (batch, _) = server.get_batch(0).await;
assert_json_snapshot!(batch, assert_json_snapshot!(batch,

View File

@ -1274,7 +1274,7 @@ async fn error_add_documents_bad_document_id() {
"content": "foobar" "content": "foobar"
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(1).await; let (response, code) = index.get_task(1).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1390,7 +1390,7 @@ async fn error_add_documents_missing_document_id() {
"content": "foobar" "content": "foobar"
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(1).await; let (response, code) = index.get_task(1).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1702,7 +1702,7 @@ async fn add_documents_with_geo_field() {
}, },
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
let response = index.wait_task(task.uid()).await; let response = index.wait_task(task.uid()).await;
snapshot!(json_string!(response, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }), snapshot!(json_string!(response, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }),
@r###" @r###"
@ -1741,7 +1741,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(2).await; let (response, code) = index.get_task(2).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1779,7 +1779,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(3).await; let (response, code) = index.get_task(3).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1817,7 +1817,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(4).await; let (response, code) = index.get_task(4).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1855,7 +1855,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1893,7 +1893,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1931,7 +1931,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -1969,7 +1969,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -2007,7 +2007,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -2045,7 +2045,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -2083,7 +2083,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -2121,7 +2121,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -2159,7 +2159,7 @@ async fn add_documents_invalid_geo_field() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -2409,7 +2409,7 @@ async fn error_primary_key_inference() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(0).await; let (response, code) = index.get_task(0).await;
assert_eq!(code, 200); assert_eq!(code, 200);
@ -2450,7 +2450,7 @@ async fn error_primary_key_inference() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
assert_eq!(code, 200); assert_eq!(code, 200);
@ -2489,7 +2489,7 @@ async fn error_primary_key_inference() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(task.uid()).await; let (response, code) = index.get_task(task.uid()).await;
assert_eq!(code, 200); assert_eq!(code, 200);
@ -2528,12 +2528,12 @@ async fn add_documents_with_primary_key_twice() {
} }
]); ]);
let (task,_status_code) = index.add_documents(documents.clone(), Some("title")).await; let (task, _status_code) = index.add_documents(documents.clone(), Some("title")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, _code) = index.get_task(task.uid()).await; let (response, _code) = index.get_task(task.uid()).await;
assert_eq!(response["status"], "succeeded"); assert_eq!(response["status"], "succeeded");
let (task,_status_code) = index.add_documents(documents, Some("title")).await; let (task, _status_code) = index.add_documents(documents, Some("title")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, _code) = index.get_task(task.uid()).await; let (response, _code) = index.get_task(task.uid()).await;
assert_eq!(response["status"], "succeeded"); assert_eq!(response["status"], "succeeded");

View File

@ -30,9 +30,10 @@ async fn delete_one_unexisting_document() {
async fn delete_one_document() { async fn delete_one_document() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(json!([{ "id": 0, "content": "foobar" }]), None).await; let (task, _status_code) =
index.add_documents(json!([{ "id": 0, "content": "foobar" }]), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,status_code) = server.index("test").delete_document(0).await; let (task, status_code) = server.index("test").delete_document(0).await;
assert_eq!(status_code, 202); assert_eq!(status_code, 202);
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
@ -56,7 +57,7 @@ async fn clear_all_documents_unexisting_index() {
async fn clear_all_documents() { async fn clear_all_documents() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index let (task, _status_code) = index
.add_documents( .add_documents(
json!([{ "id": 1, "content": "foobar" }, { "id": 0, "content": "foobar" }]), json!([{ "id": 1, "content": "foobar" }, { "id": 0, "content": "foobar" }]),
None, None,
@ -76,7 +77,7 @@ async fn clear_all_documents() {
async fn clear_all_documents_empty_index() { async fn clear_all_documents_empty_index() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, code) = index.clear_all_documents().await; let (task, code) = index.clear_all_documents().await;
assert_eq!(code, 202); assert_eq!(code, 202);
@ -143,7 +144,7 @@ async fn delete_document_by_filter() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("doggo"); let index = server.index("doggo");
index.update_settings_filterable_attributes(json!(["color"])).await; index.update_settings_filterable_attributes(json!(["color"])).await;
let (task,_status_code) = index let (task, _status_code) = index
.add_documents( .add_documents(
json!([ json!([
{ "id": 0, "color": "red" }, { "id": 0, "color": "red" },
@ -303,7 +304,7 @@ async fn delete_document_by_complex_filter() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("doggo"); let index = server.index("doggo");
index.update_settings_filterable_attributes(json!(["color"])).await; index.update_settings_filterable_attributes(json!(["color"])).await;
let (task,_status_code) = index let (task, _status_code) = index
.add_documents( .add_documents(
json!([ json!([
{ "id": 0, "color": "red" }, { "id": 0, "color": "red" },

View File

@ -55,7 +55,7 @@ async fn no_index_return_empty_list() {
async fn list_multiple_indexes() { async fn list_multiple_indexes() {
let server = Server::new().await; let server = Server::new().await;
server.index("test").create(None).await; server.index("test").create(None).await;
let (task,_status_code) = server.index("test1").create(Some("key")).await; let (task, _status_code) = server.index("test1").create(Some("key")).await;
server.index("test").wait_task(task.uid()).await.succeeded(); server.index("test").wait_task(task.uid()).await.succeeded();

View File

@ -13,7 +13,7 @@ async fn update_primary_key() {
assert_eq!(code, 202); assert_eq!(code, 202);
let (task,_status_code) = index.update(Some("primary")).await; let (task, _status_code) = index.update(Some("primary")).await;
let response = index.wait_task(task.uid()).await; let response = index.wait_task(task.uid()).await;
@ -46,7 +46,7 @@ async fn create_and_update_with_different_encoding() {
assert_eq!(code, 202); assert_eq!(code, 202);
let index = server.index_with_encoder("test", Encoder::Brotli); let index = server.index_with_encoder("test", Encoder::Brotli);
let (task,_status_code) = index.update(Some("primary")).await; let (task, _status_code) = index.update(Some("primary")).await;
let response = index.wait_task(task.uid()).await; let response = index.wait_task(task.uid()).await;

View File

@ -151,7 +151,7 @@ async fn distinct_search_with_offset_no_ranking() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await; index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await;
let (task,_status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await; let (task, _status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
fn get_hits(response: &Value) -> Vec<&str> { fn get_hits(response: &Value) -> Vec<&str> {
@ -210,7 +210,7 @@ async fn distinct_search_with_pagination_no_ranking() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await; index.add_documents(documents, Some(DOCUMENT_PRIMARY_KEY)).await;
let (task,_status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await; let (task, _status_code) = index.update_distinct_attribute(json!(DOCUMENT_DISTINCT_KEY)).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
fn get_hits(response: &Value) -> Vec<&str> { fn get_hits(response: &Value) -> Vec<&str> {

View File

@ -41,7 +41,7 @@ async fn simple_facet_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -175,7 +175,7 @@ async fn advanced_facet_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.update_settings_typo_tolerance(json!({ "enabled": false })).await; index.update_settings_typo_tolerance(json!({ "enabled": false })).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -199,7 +199,7 @@ async fn more_advanced_facet_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.update_settings_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).await; index.update_settings_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -223,7 +223,7 @@ async fn simple_facet_search_with_max_values() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_faceting(json!({ "maxValuesPerFacet": 1 })).await; index.update_settings_faceting(json!({ "maxValuesPerFacet": 1 })).await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -245,7 +245,7 @@ async fn simple_facet_search_by_count_with_max_values() {
) )
.await; .await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -261,7 +261,7 @@ async fn non_filterable_facet_search_error() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -280,7 +280,7 @@ async fn facet_search_dont_support_words() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -298,7 +298,7 @@ async fn simple_facet_search_with_sort_by_count() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_faceting(json!({ "sortFacetValuesBy": { "*": "count" } })).await; index.update_settings_faceting(json!({ "sortFacetValuesBy": { "*": "count" } })).await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =

View File

@ -46,7 +46,7 @@ async fn geo_sort_with_geo_strings() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["_geo"])).await; index.update_settings_filterable_attributes(json!(["_geo"])).await;
index.update_settings_sortable_attributes(json!(["_geo"])).await; index.update_settings_sortable_attributes(json!(["_geo"])).await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index

View File

@ -98,7 +98,7 @@ async fn simple_search() {
json!({"searchableAttributes": ["name_en", "name_ja", "name_zh", "author_en", "author_ja", "author_zh", "description_en", "description_ja", "description_zh"]}), json!({"searchableAttributes": ["name_en", "name_ja", "name_zh", "author_en", "author_ja", "author_zh", "description_en", "description_ja", "description_zh"]}),
) )
.await; .await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// english // english
@ -220,7 +220,7 @@ async fn force_locales() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// chinese detection // chinese detection
@ -298,7 +298,7 @@ async fn force_locales_with_pattern() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// chinese detection // chinese detection
@ -374,7 +374,7 @@ async fn force_locales_with_pattern_nested() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// chinese // chinese
@ -449,7 +449,7 @@ async fn force_different_locales_with_pattern() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// force chinese // force chinese
@ -527,7 +527,7 @@ async fn auto_infer_locales_at_search_with_attributes_to_search_on() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// auto infer any language // auto infer any language
@ -601,7 +601,7 @@ async fn auto_infer_locales_at_search() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -700,7 +700,7 @@ async fn force_different_locales_with_pattern_nested() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// chinese // chinese
@ -778,7 +778,7 @@ async fn settings_change() {
let index = server.index("test"); let index = server.index("test");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, _) = index let (response, _) = index
.update_settings(json!({ .update_settings(json!({
@ -915,7 +915,7 @@ async fn invalid_locales() {
json!({"searchableAttributes": ["name_en", "name_ja", "name_zh", "author_en", "author_ja", "author_zh", "description_en", "description_ja", "description_zh"]}), json!({"searchableAttributes": ["name_en", "name_ja", "name_zh", "author_en", "author_ja", "author_zh", "description_en", "description_ja", "description_zh"]}),
) )
.await; .await;
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.search_post(json!({"q": "Atta", "locales": ["invalid"]})).await; let (response, code) = index.search_post(json!({"q": "Atta", "locales": ["invalid"]})).await;
@ -1033,7 +1033,7 @@ async fn simple_facet_search() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, _) = index let (response, _) = index
@ -1095,7 +1095,7 @@ async fn facet_search_with_localized_attributes() {
"enqueuedAt": "[date]" "enqueuedAt": "[date]"
} }
"###); "###);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, _) = index let (response, _) = index

View File

@ -8,7 +8,7 @@ use crate::json;
async fn index_with_documents<'a>(server: &'a Server, documents: &Value) -> Index<'a> { async fn index_with_documents<'a>(server: &'a Server, documents: &Value) -> Index<'a> {
let index = server.index("test"); let index = server.index("test");
let(task,_status_code) =index.add_documents(documents.clone(), None).await; let (task, _status_code) = index.add_documents(documents.clone(), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
} }

View File

@ -138,7 +138,7 @@ async fn phrase_search_with_stop_word() {
meili_snap::snapshot!(code, @"202 Accepted"); meili_snap::snapshot!(code, @"202 Accepted");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -218,10 +218,11 @@ async fn negative_special_cases_search() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = index.update_settings(json!({"synonyms": { "escape": ["gläss"] }})).await; let (task, _status_code) =
index.update_settings(json!({"synonyms": { "escape": ["gläss"] }})).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// There is a synonym for escape -> glass but we don't want "escape", only the derivates: glass // There is a synonym for escape -> glass but we don't want "escape", only the derivates: glass
@ -247,7 +248,7 @@ async fn test_kanji_language_detection() {
{ "id": 1, "title": "東京のお寿司。" }, { "id": 1, "title": "東京のお寿司。" },
{ "id": 2, "title": "הַשּׁוּעָל הַמָּהִיר (״הַחוּם״) לֹא יָכוֹל לִקְפֹּץ 9.94 מֶטְרִים, נָכוֹן? ברר, 1.5°C- בַּחוּץ!" } { "id": 2, "title": "הַשּׁוּעָל הַמָּהִיר (״הַחוּם״) לֹא יָכוֹל לִקְפֹּץ 9.94 מֶטְרִים, נָכוֹן? ברר, 1.5°C- בַּחוּץ!" }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -270,10 +271,10 @@ async fn test_thai_language() {
{ "id": 1, "title": "สบู่สมุนไพรชาเขียว 100 กรัม จำนวน 6 ก้อน" }, { "id": 1, "title": "สบู่สมุนไพรชาเขียว 100 กรัม จำนวน 6 ก้อน" },
{ "id": 2, "title": "สบู่สมุนไพรฝางแดงผสมว่านหางจรเข้ 100 กรัม จำนวน 6 ก้อน" } { "id": 2, "title": "สบู่สมุนไพรฝางแดงผสมว่านหางจรเข้ 100 กรัม จำนวน 6 ก้อน" }
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = index.update_settings(json!({"rankingRules": ["exactness"]})).await; let (task, _status_code) = index.update_settings(json!({"rankingRules": ["exactness"]})).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -607,7 +608,7 @@ async fn displayed_attributes() {
index.update_settings(json!({ "displayedAttributes": ["title"] })).await; index.update_settings(json!({ "displayedAttributes": ["title"] })).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = let (response, code) =
@ -622,7 +623,7 @@ async fn placeholder_search_is_hard_limited() {
let index = server.index("test"); let index = server.index("test");
let documents: Vec<_> = (0..1200).map(|i| json!({ "id": i, "text": "I am unique!" })).collect(); let documents: Vec<_> = (0..1200).map(|i| json!({ "id": i, "text": "I am unique!" })).collect();
let (task,_status_code) = index.add_documents(documents.into(), None).await; let (task, _status_code) = index.add_documents(documents.into(), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -650,7 +651,8 @@ async fn placeholder_search_is_hard_limited() {
) )
.await; .await;
let (task,_status_code) = index.update_settings(json!({ "pagination": { "maxTotalHits": 10_000 } })).await; let (task, _status_code) =
index.update_settings(json!({ "pagination": { "maxTotalHits": 10_000 } })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -685,7 +687,7 @@ async fn search_is_hard_limited() {
let index = server.index("test"); let index = server.index("test");
let documents: Vec<_> = (0..1200).map(|i| json!({ "id": i, "text": "I am unique!" })).collect(); let documents: Vec<_> = (0..1200).map(|i| json!({ "id": i, "text": "I am unique!" })).collect();
let (task,_status_code) = index.add_documents(documents.into(), None).await; let (task, _status_code) = index.add_documents(documents.into(), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -715,7 +717,8 @@ async fn search_is_hard_limited() {
) )
.await; .await;
let (task,_status_code) = index.update_settings(json!({ "pagination": { "maxTotalHits": 10_000 } })).await; let (task, _status_code) =
index.update_settings(json!({ "pagination": { "maxTotalHits": 10_000 } })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -754,7 +757,7 @@ async fn faceting_max_values_per_facet() {
index.update_settings(json!({ "filterableAttributes": ["number"] })).await; index.update_settings(json!({ "filterableAttributes": ["number"] })).await;
let documents: Vec<_> = (0..10_000).map(|id| json!({ "id": id, "number": id * 10 })).collect(); let documents: Vec<_> = (0..10_000).map(|id| json!({ "id": id, "number": id * 10 })).collect();
let (task,_status_code) = index.add_documents(json!(documents), None).await; let (task, _status_code) = index.add_documents(json!(documents), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -770,7 +773,8 @@ async fn faceting_max_values_per_facet() {
) )
.await; .await;
let (task,_status_code) = index.update_settings(json!({ "faceting": { "maxValuesPerFacet": 10_000 } })).await; let (task, _status_code) =
index.update_settings(json!({ "faceting": { "maxValuesPerFacet": 10_000 } })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -1162,7 +1166,7 @@ async fn experimental_feature_vector_store() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(json!(documents), None).await; let (task, _status_code) = index.add_documents(json!(documents), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index let (response, code) = index
@ -1369,7 +1373,7 @@ async fn camelcased_words() {
{ "id": 3, "title": "TestAb" }, { "id": 3, "title": "TestAb" },
{ "id": 4, "title": "testab" }, { "id": 4, "title": "testab" },
]); ]);
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -1587,12 +1591,13 @@ async fn simple_search_with_strange_synonyms() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.update_settings(json!({ "synonyms": {"&": ["to"], "to": ["&"]} })).await; let (task, _status_code) =
index.update_settings(json!({ "synonyms": {"&": ["to"], "to": ["&"]} })).await;
let r = index.wait_task(task.uid()).await; let r = index.wait_task(task.uid()).await;
meili_snap::snapshot!(r["status"], @r###""succeeded""###); meili_snap::snapshot!(r["status"], @r###""succeeded""###);
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -1679,7 +1684,7 @@ async fn change_attributes_settings() {
index.update_settings(json!({ "searchableAttributes": ["father", "mother"] })).await; index.update_settings(json!({ "searchableAttributes": ["father", "mother"] })).await;
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(json!(documents), None).await; let (task, _status_code) = index.add_documents(json!(documents), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = let (task,_status_code) =

View File

@ -89,7 +89,7 @@ async fn simple_search_single_index() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -161,7 +161,7 @@ async fn federation_single_search_single_index() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -208,7 +208,7 @@ async fn federation_multiple_search_single_index() {
let index = server.index("test"); let index = server.index("test");
let documents = SCORE_DOCUMENTS.clone(); let documents = SCORE_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -283,7 +283,7 @@ async fn federation_two_search_single_index() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -351,7 +351,7 @@ async fn simple_search_missing_index_uid() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -376,7 +376,7 @@ async fn federation_simple_search_missing_index_uid() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -401,7 +401,7 @@ async fn simple_search_illegal_index_uid() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -426,7 +426,7 @@ async fn federation_search_illegal_index_uid() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -451,12 +451,12 @@ async fn simple_search_two_indexes() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (add_task,_status_code) = index.add_documents(documents, None).await; let (add_task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(add_task.uid()).await.succeeded(); index.wait_task(add_task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -558,12 +558,12 @@ async fn federation_two_search_two_indexes() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -666,17 +666,17 @@ async fn federation_multiple_search_multiple_indexes() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("score"); let index = server.index("score");
let documents = SCORE_DOCUMENTS.clone(); let documents = SCORE_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -924,7 +924,7 @@ async fn search_one_index_doesnt_exist() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -950,7 +950,7 @@ async fn federation_one_index_doesnt_exist() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1021,12 +1021,12 @@ async fn search_one_query_error() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1053,12 +1053,12 @@ async fn federation_one_query_error() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1085,12 +1085,12 @@ async fn federation_one_query_sort_error() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1117,12 +1117,12 @@ async fn search_multiple_query_errors() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1149,12 +1149,12 @@ async fn federation_multiple_query_errors() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1181,12 +1181,12 @@ async fn federation_multiple_query_sort_errors() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1213,12 +1213,12 @@ async fn federation_multiple_query_errors_interleaved() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -1246,12 +1246,12 @@ async fn federation_multiple_query_sort_errors_interleaved() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = server let (response, code) = server
@ -3020,17 +3020,17 @@ async fn federation_limit_offset() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("score"); let index = server.index("score");
let documents = SCORE_DOCUMENTS.clone(); let documents = SCORE_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
{ {
let (response, code) = server let (response, code) = server
@ -3338,17 +3338,17 @@ async fn federation_formatting() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("nested"); let index = server.index("nested");
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let index = server.index("score"); let index = server.index("score");
let documents = SCORE_DOCUMENTS.clone(); let documents = SCORE_DOCUMENTS.clone();
let (task,_status_code) = index.add_documents(documents, None).await; let (task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
{ {
let (response, code) = server let (response, code) = server

View File

@ -65,7 +65,7 @@ async fn search_no_searchable_attribute_set() {
) )
.await; .await;
let (task,_status_code) = index.update_settings_searchable_attributes(json!(["*"])).await; let (task, _status_code) = index.update_settings_searchable_attributes(json!(["*"])).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -78,7 +78,7 @@ async fn search_no_searchable_attribute_set() {
) )
.await; .await;
let (task,_status_code) = index.update_settings_searchable_attributes(json!(["*"])).await; let (task, _status_code) = index.update_settings_searchable_attributes(json!(["*"])).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -109,7 +109,7 @@ async fn search_on_all_attributes() {
async fn search_on_all_attributes_restricted_set() { async fn search_on_all_attributes_restricted_set() {
let server = Server::new().await; let server = Server::new().await;
let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await; let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;
let (task,_status_code) = index.update_settings_searchable_attributes(json!(["title"])).await; let (task, _status_code) = index.update_settings_searchable_attributes(json!(["title"])).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
@ -192,7 +192,9 @@ async fn word_ranking_rule_order() {
async fn word_ranking_rule_order_exact_words() { async fn word_ranking_rule_order_exact_words() {
let server = Server::new().await; let server = Server::new().await;
let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await; let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;
let (task,_status_code) = index.update_settings_typo_tolerance(json!({"disableOnWords": ["Captain", "Marvel"]})).await; let (task, _status_code) = index
.update_settings_typo_tolerance(json!({"disableOnWords": ["Captain", "Marvel"]}))
.await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// simple search should return 2 documents (ids: 2 and 3). // simple search should return 2 documents (ids: 2 and 3).

View File

@ -13,7 +13,7 @@ async fn set_and_reset_distinct_attribute() {
assert_eq!(response["distinctAttribute"], "test"); assert_eq!(response["distinctAttribute"], "test");
let (task2,_status_code) = index.update_settings(json!({ "distinctAttribute": null })).await; let (task2, _status_code) = index.update_settings(json!({ "distinctAttribute": null })).await;
index.wait_task(task2.uid()).await.succeeded(); index.wait_task(task2.uid()).await.succeeded();
@ -34,7 +34,7 @@ async fn set_and_reset_distinct_attribute_with_dedicated_route() {
assert_eq!(response, "test"); assert_eq!(response, "test");
let (update_task2,_status_code) = index.update_distinct_attribute(json!(null)).await; let (update_task2, _status_code) = index.update_distinct_attribute(json!(null)).await;
index.wait_task(update_task2.uid()).await.succeeded(); index.wait_task(update_task2.uid()).await.succeeded();

View File

@ -436,7 +436,7 @@ async fn reset_all_settings() {
assert_eq!(response["synonyms"], json!({"puppy": ["dog", "doggo", "potat"] })); assert_eq!(response["synonyms"], json!({"puppy": ["dog", "doggo", "potat"] }));
assert_eq!(response["filterableAttributes"], json!(["age"])); assert_eq!(response["filterableAttributes"], json!(["age"]));
let (delete_task,_status_code) = index.delete_settings().await; let (delete_task, _status_code) = index.delete_settings().await;
index.wait_task(delete_task.uid()).await.succeeded(); index.wait_task(delete_task.uid()).await.succeeded();
let (response, code) = index.settings().await; let (response, code) = index.settings().await;
@ -462,7 +462,7 @@ async fn update_setting_unexisting_index() {
assert_eq!(response["status"], "succeeded"); assert_eq!(response["status"], "succeeded");
let (_response, code) = index.get().await; let (_response, code) = index.get().await;
assert_eq!(code, 200); assert_eq!(code, 200);
let (task,_status_code) = index.delete_settings().await; let (task, _status_code) = index.delete_settings().await;
let response = index.wait_task(task.uid()).await; let response = index.wait_task(task.uid()).await;
assert_eq!(response["status"], "succeeded"); assert_eq!(response["status"], "succeeded");
} }
@ -513,7 +513,7 @@ async fn set_and_reset_distinct_attribute_with_dedicated_route() {
assert_eq!(response, "test"); assert_eq!(response, "test");
let (task,_status_code) = index.update_distinct_attribute(json!(null)).await; let (task, _status_code) = index.update_distinct_attribute(json!(null)).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();

View File

@ -29,7 +29,7 @@ async fn attribute_scale_search() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(DOCUMENTS.clone(), None).await; let (task, _status_code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index let (response, code) = index
@ -102,7 +102,7 @@ async fn attribute_scale_phrase_search() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(DOCUMENTS.clone(), None).await; let (task, _status_code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _code) = index let (task, _code) = index
@ -170,7 +170,7 @@ async fn word_scale_set_and_reset() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(DOCUMENTS.clone(), None).await; let (task, _status_code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
// Set and reset the setting ensuring the swap between the 2 settings is applied. // Set and reset the setting ensuring the swap between the 2 settings is applied.
@ -285,7 +285,7 @@ async fn attribute_scale_default_ranking_rules() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(DOCUMENTS.clone(), None).await; let (task, _status_code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index let (response, code) = index

View File

@ -38,7 +38,7 @@ async fn set_and_reset() {
] ]
"###); "###);
let (task,_status_code) = index let (task, _status_code) = index
.update_settings(json!({ .update_settings(json!({
"nonSeparatorTokens": null, "nonSeparatorTokens": null,
"separatorTokens": null, "separatorTokens": null,
@ -74,7 +74,7 @@ async fn set_and_search() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (add_task,_status_code) = index.add_documents(documents, None).await; let (add_task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(add_task.uid()).await.succeeded(); index.wait_task(add_task.uid()).await.succeeded();
let (update_task, _code) = index let (update_task, _code) = index
@ -228,7 +228,7 @@ async fn advanced_synergies() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (add_task,_status_code) = index.add_documents(documents, None).await; let (add_task, _status_code) = index.add_documents(documents, None).await;
index.wait_task(add_task.uid()).await.succeeded(); index.wait_task(add_task.uid()).await.succeeded();
let (update_task, _code) = index let (update_task, _code) = index

View File

@ -129,10 +129,10 @@ async fn perform_on_demand_snapshot() {
index.load_test_set().await; index.load_test_set().await;
let (task,_status_code) = server.index("doggo").create(Some("bone")).await; let (task, _status_code) = server.index("doggo").create(Some("bone")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = server.index("doggo").create(Some("bone")).await; let (task, _status_code) = server.index("doggo").create(Some("bone")).await;
index.wait_task(task.uid()).await.failed(); index.wait_task(task.uid()).await.failed();
let (task, code) = server.create_snapshot().await; let (task, code) = server.create_snapshot().await;

View File

@ -13,7 +13,7 @@ use crate::json;
async fn error_get_unexisting_task_status() { async fn error_get_unexisting_task_status() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get_task(1).await; let (response, code) = index.get_task(1).await;
@ -32,8 +32,8 @@ async fn error_get_unexisting_task_status() {
async fn get_task_status() { async fn get_task_status() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (create_task,_status_code) = index.create(None).await; let (create_task, _status_code) = index.create(None).await;
let (add_task,_status_code) = index let (add_task, _status_code) = index
.add_documents( .add_documents(
json!([{ json!([{
"id": 1, "id": 1,
@ -52,7 +52,7 @@ async fn get_task_status() {
async fn list_tasks() { async fn list_tasks() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -149,7 +149,7 @@ async fn list_tasks_with_star_filters() {
async fn list_tasks_status_filtered() { async fn list_tasks_status_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -175,7 +175,7 @@ async fn list_tasks_status_filtered() {
async fn list_tasks_type_filtered() { async fn list_tasks_type_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -195,7 +195,7 @@ async fn list_tasks_type_filtered() {
async fn list_tasks_invalid_canceled_by_filter() { async fn list_tasks_invalid_canceled_by_filter() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -210,7 +210,7 @@ async fn list_tasks_invalid_canceled_by_filter() {
async fn list_tasks_status_and_type_filtered() { async fn list_tasks_status_and_type_filtered() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
@ -278,7 +278,8 @@ async fn test_summarized_task_view() {
async fn test_summarized_document_addition_or_update() { async fn test_summarized_document_addition_or_update() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), None).await; let (task, _status_code) =
index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(0).await; let (task, _) = index.get_task(0).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -303,7 +304,8 @@ async fn test_summarized_document_addition_or_update() {
} }
"###); "###);
let (task,_status_code) = index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), Some("id")).await; let (task, _status_code) =
index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), Some("id")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(1).await; let (task, _) = index.get_task(1).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -333,7 +335,7 @@ async fn test_summarized_document_addition_or_update() {
async fn test_summarized_delete_documents_by_batch() { async fn test_summarized_delete_documents_by_batch() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.delete_batch(vec![1, 2, 3]).await; let (task, _status_code) = index.delete_batch(vec![1, 2, 3]).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(0).await; let (task, _) = index.get_task(0).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -365,7 +367,7 @@ async fn test_summarized_delete_documents_by_batch() {
"###); "###);
index.create(None).await; index.create(None).await;
let (del_task,_status_code) = index.delete_batch(vec![42]).await; let (del_task, _status_code) = index.delete_batch(vec![42]).await;
index.wait_task(del_task.uid()).await.succeeded(); index.wait_task(del_task.uid()).await.succeeded();
let (task, _) = index.get_task(del_task.uid()).await; let (task, _) = index.get_task(del_task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -397,7 +399,8 @@ async fn test_summarized_delete_documents_by_filter() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; let (task, _status_code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -429,7 +432,8 @@ async fn test_summarized_delete_documents_by_filter() {
"###); "###);
index.create(None).await; index.create(None).await;
let (task,_status_code) = index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; let (task, _status_code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -461,7 +465,8 @@ async fn test_summarized_delete_documents_by_filter() {
"###); "###);
index.update_settings(json!({ "filterableAttributes": ["doggo"] })).await; index.update_settings(json!({ "filterableAttributes": ["doggo"] })).await;
let (task,_status_code) = index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; let (task, _status_code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -492,7 +497,7 @@ async fn test_summarized_delete_documents_by_filter() {
async fn test_summarized_delete_document_by_id() { async fn test_summarized_delete_document_by_id() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.delete_document(1).await; let (task, _status_code) = index.delete_document(1).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -524,7 +529,7 @@ async fn test_summarized_delete_document_by_id() {
"###); "###);
index.create(None).await; index.create(None).await;
let (task,_status_code) = index.delete_document(42).await; let (task, _status_code) = index.delete_document(42).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -606,7 +611,7 @@ async fn test_summarized_settings_update() {
async fn test_summarized_index_creation() { async fn test_summarized_index_creation() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -630,7 +635,7 @@ async fn test_summarized_index_creation() {
} }
"###); "###);
let (task,_status_code) = index.create(Some("doggos")).await; let (task, _status_code) = index.create(Some("doggos")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -774,7 +779,7 @@ async fn test_summarized_index_update() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
// If the index doesn't exist yet, we should get errors with or without the primary key. // If the index doesn't exist yet, we should get errors with or without the primary key.
let (task,_status_code) = index.update(None).await; let (task, _status_code) = index.update(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -803,7 +808,7 @@ async fn test_summarized_index_update() {
} }
"###); "###);
let (task,_status_code) = index.update(Some("bones")).await; let (task, _status_code) = index.update(Some("bones")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -835,7 +840,7 @@ async fn test_summarized_index_update() {
// And run the same two tests once the index do exists. // And run the same two tests once the index do exists.
index.create(None).await; index.create(None).await;
let (task,_status_code) = index.update(None).await; let (task, _status_code) = index.update(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -859,7 +864,7 @@ async fn test_summarized_index_update() {
} }
"###); "###);
let (task,_status_code) = index.update(Some("bones")).await; let (task, _status_code) = index.update(Some("bones")).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -887,7 +892,7 @@ async fn test_summarized_index_update() {
#[actix_web::test] #[actix_web::test]
async fn test_summarized_index_swap() { async fn test_summarized_index_swap() {
let server = Server::new().await; let server = Server::new().await;
let (task,_status_code) = server let (task, _status_code) = server
.index_swap(json!([ .index_swap(json!([
{ "indexes": ["doggos", "cattos"] } { "indexes": ["doggos", "cattos"] }
])) ]))
@ -928,7 +933,7 @@ async fn test_summarized_index_swap() {
"###); "###);
server.index("doggos").create(None).await; server.index("doggos").create(None).await;
let (task,_status_code) = server.index("cattos").create(None).await; let (task, _status_code) = server.index("cattos").create(None).await;
server server
.index_swap(json!([ .index_swap(json!([
{ "indexes": ["doggos", "cattos"] } { "indexes": ["doggos", "cattos"] }
@ -970,9 +975,9 @@ async fn test_summarized_task_cancelation() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("doggos"); let index = server.index("doggos");
// to avoid being flaky we're only going to cancel an already finished task :( // to avoid being flaky we're only going to cancel an already finished task :(
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = server.cancel_tasks("uids=0").await; let (task, _status_code) = server.cancel_tasks("uids=0").await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -1004,9 +1009,9 @@ async fn test_summarized_task_deletion() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("doggos"); let index = server.index("doggos");
// to avoid being flaky we're only going to delete an already finished task :( // to avoid being flaky we're only going to delete an already finished task :(
let (task,_status_code) = index.create(None).await; let (task, _status_code) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task,_status_code) = server.delete_tasks("uids=0").await; let (task, _status_code) = server.delete_tasks("uids=0").await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
let (task, _) = index.get_task(task.uid()).await; let (task, _) = index.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -1036,7 +1041,7 @@ async fn test_summarized_task_deletion() {
#[actix_web::test] #[actix_web::test]
async fn test_summarized_dump_creation() { async fn test_summarized_dump_creation() {
let server = Server::new().await; let server = Server::new().await;
let (task,_status_code) = server.create_dump().await; let (task, _status_code) = server.create_dump().await;
server.wait_task(task.uid()).await; server.wait_task(task.uid()).await;
let (task, _) = server.get_task(task.uid()).await; let (task, _) = server.get_task(task.uid()).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,