mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
Add a test to validate the faceting.max_values_per_facet setting
This commit is contained in:
parent
1e3dcbea3f
commit
5cd13cc303
@ -605,3 +605,52 @@ async fn search_is_hard_limited() {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn faceting_max_values_per_facet() {
|
||||||
|
let server = Server::new().await;
|
||||||
|
let index = server.index("test");
|
||||||
|
|
||||||
|
index
|
||||||
|
.update_settings(json!({ "filterableAttributes": ["number"] }))
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let documents: Vec<_> = (0..10_000)
|
||||||
|
.map(|id| json!({ "id": id, "number": id * 10 }))
|
||||||
|
.collect();
|
||||||
|
index.add_documents(json!(documents), None).await;
|
||||||
|
index.wait_task(1).await;
|
||||||
|
|
||||||
|
index
|
||||||
|
.search(
|
||||||
|
json!({
|
||||||
|
"facets": ["number"]
|
||||||
|
}),
|
||||||
|
|response, code| {
|
||||||
|
assert_eq!(code, 200, "{}", response);
|
||||||
|
let numbers = response["facetDistribution"]["number"].as_object().unwrap();
|
||||||
|
assert_eq!(numbers.len(), 100);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
index
|
||||||
|
.update_settings(json!({ "faceting": { "maxValuesPerFacet": 10_000 } }))
|
||||||
|
.await;
|
||||||
|
index.wait_task(2).await;
|
||||||
|
|
||||||
|
index
|
||||||
|
.search(
|
||||||
|
json!({
|
||||||
|
"facets": ["number"]
|
||||||
|
}),
|
||||||
|
|response, code| {
|
||||||
|
assert_eq!(code, 200, "{}", response);
|
||||||
|
let numbers = dbg!(&response)["facetDistribution"]["number"]
|
||||||
|
.as_object()
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(numbers.len(), 10_000);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user