2524: Add the specific routes for the pagination and faceting settings r=curquiza a=Kerollmops

Fixes #2522

Co-authored-by: Kerollmops <clement@meilisearch.com>
This commit is contained in:
bors[bot] 2022-06-15 17:01:52 +00:00 committed by GitHub
commit b455c3897f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 11 deletions

View File

@ -349,7 +349,9 @@ generate_configure!(
stop_words, stop_words,
synonyms, synonyms,
ranking_rules, ranking_rules,
typo_tolerance typo_tolerance,
pagination,
faceting
); );
pub async fn update_all( pub async fn update_all(
@ -409,6 +411,18 @@ pub async fn update_all(
.map(|s| s.two_typos.set())) .map(|s| s.two_typos.set()))
.flatten(), .flatten(),
}, },
"faceting": {
"max_values_per_facet": settings.faceting
.as_ref()
.set()
.and_then(|s| s.max_values_per_facet.as_ref().set()),
},
"pagination": {
"limited_to": settings.pagination
.as_ref()
.set()
.and_then(|s| s.limited_to.as_ref().set()),
},
}), }),
Some(&req), Some(&req),
); );

View File

@ -27,7 +27,13 @@ static DEFAULT_SETTINGS_VALUES: Lazy<HashMap<&'static str, Value>> = Lazy::new(|
map.insert( map.insert(
"faceting", "faceting",
json!({ json!({
"maxValuesByFacet": json!(100), "maxValuesPerFacet": json!(100),
}),
);
map.insert(
"pagination",
json!({
"limitedTo": json!(1000),
}), }),
); );
map map
@ -206,7 +212,7 @@ async fn error_update_setting_unexisting_index_invalid_uid() {
} }
macro_rules! test_setting_routes { macro_rules! test_setting_routes {
($($setting:ident), *) => { ($($setting:ident $write_method:ident), *) => {
$( $(
mod $setting { mod $setting {
use crate::common::Server; use crate::common::Server;
@ -232,7 +238,7 @@ macro_rules! test_setting_routes {
.chars() .chars()
.map(|c| if c == '_' { '-' } else { c }) .map(|c| if c == '_' { '-' } else { c })
.collect::<String>()); .collect::<String>());
let (response, code) = server.service.put(url, serde_json::Value::Null).await; let (response, code) = server.service.$write_method(url, serde_json::Value::Null).await;
assert_eq!(code, 202, "{}", response); assert_eq!(code, 202, "{}", response);
server.index("").wait_task(0).await; server.index("").wait_task(0).await;
let (response, code) = server.index("test").get().await; let (response, code) = server.index("test").get().await;
@ -276,13 +282,15 @@ macro_rules! test_setting_routes {
} }
test_setting_routes!( test_setting_routes!(
filterable_attributes, filterable_attributes put,
displayed_attributes, displayed_attributes put,
searchable_attributes, searchable_attributes put,
distinct_attribute, distinct_attribute put,
stop_words, stop_words put,
ranking_rules, ranking_rules put,
synonyms synonyms put,
pagination patch,
faceting patch
); );
#[actix_rt::test] #[actix_rt::test]