From 35bbe1c2a206f18d8a0735576b69db2605150cc2 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Wed, 20 Nov 2024 14:48:12 +0100 Subject: [PATCH] Add failing test on settings changes --- crates/meilisearch/tests/search/mod.rs | 94 ++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/crates/meilisearch/tests/search/mod.rs b/crates/meilisearch/tests/search/mod.rs index afac667bb..e39d0fc5a 100644 --- a/crates/meilisearch/tests/search/mod.rs +++ b/crates/meilisearch/tests/search/mod.rs @@ -1604,3 +1604,97 @@ async fn simple_search_with_strange_synonyms() { }) .await; } + +#[actix_rt::test] +async fn change_attributes_settings() { + let server = Server::new().await; + let index = server.index("test"); + + index.update_settings(json!({ "searchableAttributes": ["father", "mother"] })).await; + + let documents = NESTED_DOCUMENTS.clone(); + index.add_documents(json!(documents), None).await; + index.wait_task(1).await; + + index.update_settings(json!({ "searchableAttributes": ["father", "mother", "doggos"], "filterableAttributes": ["doggos"] })).await; + index.wait_task(2).await; + + // search + index + .search( + json!({ + "q": "bobby" + }), + |response, code| { + assert_eq!(code, 200, "{}", response); + meili_snap::snapshot!(meili_snap::json_string!(response["hits"]), @r###" + [ + { + "father": "jean", + "mother": "michelle", + "id": 852, + "doggos": [ + { + "name": "bobby", + "age": 2 + }, + { + "name": "buddy", + "age": 4 + } + ], + "cattos": "pésti", + "_vectors": { + "manual": [ + 1.0, + 2.0, + 3.0 + ] + } + } + ] + "###); + }, + ) + .await; + + // filter + index + .search( + json!({ + "q": "", + "filter": "doggos.age < 5" + }), + |response, code| { + assert_eq!(code, 200, "{}", response); + meili_snap::snapshot!(meili_snap::json_string!(response["hits"]), @r###" + [ + { + "father": "jean", + "mother": "michelle", + "id": 852, + "doggos": [ + { + "name": "bobby", + "age": 2 + }, + { + "name": "buddy", + "age": 4 + } + ], + "cattos": "pésti", + "_vectors": { + "manual": [ + 1.0, + 2.0, + 3.0 + ] + } + } + ] + "###); + }, + ) + .await; +}