564: Rename the limitedTo parameter into maxTotalHits r=curquiza a=Kerollmops

This PR is related to https://github.com/meilisearch/meilisearch/issues/2542, it renames the `limitedTo` parameter into `maxTotalHits`.

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

View File

@ -57,7 +57,7 @@ pub mod main_key {
pub const EXACT_WORDS: &str = "exact-words"; pub const EXACT_WORDS: &str = "exact-words";
pub const EXACT_ATTRIBUTES: &str = "exact-attributes"; pub const EXACT_ATTRIBUTES: &str = "exact-attributes";
pub const MAX_VALUES_PER_FACET: &str = "max-values-per-facet"; pub const MAX_VALUES_PER_FACET: &str = "max-values-per-facet";
pub const PAGINATION_LIMITED_TO: &str = "pagination-limited-to"; pub const PAGINATION_MAX_TOTAL_HITS: &str = "pagination-max-total-hits";
} }
pub mod db_name { pub mod db_name {
@ -1102,20 +1102,20 @@ impl Index {
self.main.delete::<_, Str>(txn, main_key::MAX_VALUES_PER_FACET) self.main.delete::<_, Str>(txn, main_key::MAX_VALUES_PER_FACET)
} }
pub fn pagination_limited_to(&self, txn: &RoTxn) -> heed::Result<Option<usize>> { pub fn pagination_max_total_hits(&self, txn: &RoTxn) -> heed::Result<Option<usize>> {
self.main.get::<_, Str, OwnedType<usize>>(txn, main_key::PAGINATION_LIMITED_TO) self.main.get::<_, Str, OwnedType<usize>>(txn, main_key::PAGINATION_MAX_TOTAL_HITS)
} }
pub(crate) fn put_pagination_limited_to( pub(crate) fn put_pagination_max_total_hits(
&self, &self,
txn: &mut RwTxn, txn: &mut RwTxn,
val: usize, val: usize,
) -> heed::Result<()> { ) -> heed::Result<()> {
self.main.put::<_, Str, OwnedType<usize>>(txn, main_key::PAGINATION_LIMITED_TO, &val) self.main.put::<_, Str, OwnedType<usize>>(txn, main_key::PAGINATION_MAX_TOTAL_HITS, &val)
} }
pub(crate) fn delete_pagination_limited_to(&self, txn: &mut RwTxn) -> heed::Result<bool> { pub(crate) fn delete_pagination_max_total_hits(&self, txn: &mut RwTxn) -> heed::Result<bool> {
self.main.delete::<_, Str>(txn, main_key::PAGINATION_LIMITED_TO) self.main.delete::<_, Str>(txn, main_key::PAGINATION_MAX_TOTAL_HITS)
} }
} }

View File

@ -105,7 +105,7 @@ pub struct Settings<'a, 't, 'u, 'i> {
/// Attributes on which typo tolerance is disabled. /// Attributes on which typo tolerance is disabled.
exact_attributes: Setting<HashSet<String>>, exact_attributes: Setting<HashSet<String>>,
max_values_per_facet: Setting<usize>, max_values_per_facet: Setting<usize>,
pagination_limited_to: Setting<usize>, pagination_max_total_hits: Setting<usize>,
} }
impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> { impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
@ -132,7 +132,7 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
min_word_len_one_typo: Setting::NotSet, min_word_len_one_typo: Setting::NotSet,
exact_attributes: Setting::NotSet, exact_attributes: Setting::NotSet,
max_values_per_facet: Setting::NotSet, max_values_per_facet: Setting::NotSet,
pagination_limited_to: Setting::NotSet, pagination_max_total_hits: Setting::NotSet,
indexer_config, indexer_config,
} }
} }
@ -258,12 +258,12 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
self.max_values_per_facet = Setting::Reset; self.max_values_per_facet = Setting::Reset;
} }
pub fn set_pagination_limited_to(&mut self, value: usize) { pub fn set_pagination_max_total_hits(&mut self, value: usize) {
self.pagination_limited_to = Setting::Set(value); self.pagination_max_total_hits = Setting::Set(value);
} }
pub fn reset_pagination_limited_to(&mut self) { pub fn reset_pagination_max_total_hits(&mut self) {
self.pagination_limited_to = Setting::Reset; self.pagination_max_total_hits = Setting::Reset;
} }
fn reindex<F>(&mut self, cb: &F, old_fields_ids_map: FieldsIdsMap) -> Result<()> fn reindex<F>(&mut self, cb: &F, old_fields_ids_map: FieldsIdsMap) -> Result<()>
@ -646,13 +646,13 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
Ok(()) Ok(())
} }
fn update_pagination_limited_to(&mut self) -> Result<()> { fn update_pagination_max_total_hits(&mut self) -> Result<()> {
match self.pagination_limited_to { match self.pagination_max_total_hits {
Setting::Set(max) => { Setting::Set(max) => {
self.index.put_pagination_limited_to(&mut self.wtxn, max)?; self.index.put_pagination_max_total_hits(&mut self.wtxn, max)?;
} }
Setting::Reset => { Setting::Reset => {
self.index.delete_pagination_limited_to(&mut self.wtxn)?; self.index.delete_pagination_max_total_hits(&mut self.wtxn)?;
} }
Setting::NotSet => (), Setting::NotSet => (),
} }
@ -679,7 +679,7 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
self.update_min_typo_word_len()?; self.update_min_typo_word_len()?;
self.update_exact_words()?; self.update_exact_words()?;
self.update_max_values_per_facet()?; self.update_max_values_per_facet()?;
self.update_pagination_limited_to()?; self.update_pagination_max_total_hits()?;
// If there is new faceted fields we indicate that we must reindex as we must // If there is new faceted fields we indicate that we must reindex as we must
// index new fields as facets. It means that the distinct attribute, // index new fields as facets. It means that the distinct attribute,
@ -1576,7 +1576,7 @@ mod tests {
exact_words, exact_words,
exact_attributes, exact_attributes,
max_values_per_facet, max_values_per_facet,
pagination_limited_to, pagination_max_total_hits,
} = builder; } = builder;
assert!(matches!(searchable_fields, Setting::NotSet)); assert!(matches!(searchable_fields, Setting::NotSet));
@ -1594,6 +1594,6 @@ mod tests {
assert!(matches!(exact_words, Setting::NotSet)); assert!(matches!(exact_words, Setting::NotSet));
assert!(matches!(exact_attributes, Setting::NotSet)); assert!(matches!(exact_attributes, Setting::NotSet));
assert!(matches!(max_values_per_facet, Setting::NotSet)); assert!(matches!(max_values_per_facet, Setting::NotSet));
assert!(matches!(pagination_limited_to, Setting::NotSet)); assert!(matches!(pagination_max_total_hits, Setting::NotSet));
} }
} }