Repository: meilisearch/meilisearch
File: meilisearch/tests/search/restrict_searchable.rs (Rust)

Code before:

    index.update_settings_searchable_attributes(json!(["*"])).await;
    index.wait_task(1).await;

    index
        .search(
            json!({"q": "Captain Marvel", "attributesToSearchOn": ["unknown"]}),
            |response, code| {
                snapshot!(code, @"200 OK");
                snapshot!(response["hits"].as_array().unwrap().len(), @"0");
            },
        )
        .await;

    index.update_settings_searchable_attributes(json!(["description", "*", "title"])).await;
    index.wait_task(2).await;

    index
        .search(
            json!({"q": "Captain Marvel", "attributesToSearchOn": ["unknown"]}),
            |response, code| {
                snapshot!(code, @"200 OK");
                snapshot!(response["hits"].as_array().unwrap().len(), @"0");
            },
        )
        .await;
}

#[actix_rt::test]
async fn search_on_all_attributes() {
    let server = Server::new().await;
    let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;

    index
        .search(json!({"q": "Captain Marvel", "attributesToSearchOn": ["*"]}), |response, code| {
            snapshot!(code, @"200 OK");
            snapshot!(response["hits"].as_array().unwrap().len(), @"3");
        })
        .await;
}

#[actix_rt::test]
async fn search_on_all_attributes_restricted_set() {
    let server = Server::new().await;
    let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;
    index.update_settings_searchable_attributes(json!(["title"])).await;
    index.wait_task(1).await;

    index
        .search(json!({"q": "Captain Marvel", "attributesToSearchOn": ["*"]}), |response, code| {
            snapshot!(code, @"200 OK");

Review comment (suggestion):
This last part seems to test the settings more than attributesToSearchOn, what about testing a restricted search containing unknown fields?

```suggestion
    index.update_settings_searchable_attributes(json!(["*"])).await;
    index.wait_task(2).await;

    index
        .search(
            json!({"q": "Captain Marvel", "attributesToSearchOn": ["unknown", "title"]}),
            |response, code| {
                snapshot!(code, @"200 OK");
                snapshot!(response["hits"].as_array().unwrap().len(), @"2");
            },
        )
        .await;
```

Code after:

    index.update_settings_searchable_attributes(json!(["*"])).await;
    index.wait_task(1).await;

    index
        .search(
            json!({"q": "Captain Marvel", "attributesToSearchOn": ["unknown"]}),
            |response, code| {
                snapshot!(code, @"200 OK");
                snapshot!(response["hits"].as_array().unwrap().len(), @"0");
            },
        )
        .await;

    index.update_settings_searchable_attributes(json!(["*"])).await;
    index.wait_task(2).await;

    index
        .search(
            json!({"q": "Captain Marvel", "attributesToSearchOn": ["unknown", "title"]}),
            |response, code| {
                snapshot!(code, @"200 OK");
                snapshot!(response["hits"].as_array().unwrap().len(), @"2");
            },
        )
        .await;
}

#[actix_rt::test]
async fn search_on_all_attributes() {
    let server = Server::new().await;
    let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;

    index
        .search(json!({"q": "Captain Marvel", "attributesToSearchOn": ["*"]}), |response, code| {
            snapshot!(code, @"200 OK");
            snapshot!(response["hits"].as_array().unwrap().len(), @"3");
        })
        .await;
}

#[actix_rt::test]
async fn search_on_all_attributes_restricted_set() {
    let server = Server::new().await;
    let index = index_with_documents(&server, &SIMPLE_SEARCH_DOCUMENTS).await;
    index.update_settings_searchable_attributes(json!(["title"])).await;
    index.wait_task(1).await;

    index
        .search(json!({"q": "Captain Marvel", "attributesToSearchOn": ["*"]}), |response, code| {
            snapshot!(code, @"200 OK");