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; +}