diff --git a/meilisearch-core/src/settings.rs b/meilisearch-core/src/settings.rs index d0f9718f5..b97a14874 100644 --- a/meilisearch-core/src/settings.rs +++ b/meilisearch-core/src/settings.rs @@ -16,7 +16,7 @@ pub struct Settings { #[serde(default, deserialize_with = "deserialize_some")] pub ranking_rules: Option>>, #[serde(default, deserialize_with = "deserialize_some")] - pub ranking_distinct: Option>, + pub distinct_attribute: Option>, #[serde(default, deserialize_with = "deserialize_some")] pub searchable_attributes: Option>>, #[serde(default, deserialize_with = "deserialize_some")] @@ -49,7 +49,7 @@ impl Settings { Ok(SettingsUpdate { ranking_rules, - ranking_distinct: settings.ranking_distinct.into(), + distinct_attribute: settings.distinct_attribute.into(), identifier: UpdateState::Nothing, searchable_attributes: settings.searchable_attributes.into(), displayed_attributes: settings.displayed_attributes.into(), @@ -155,7 +155,7 @@ impl RankingRule { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SettingsUpdate { pub ranking_rules: UpdateState>, - pub ranking_distinct: UpdateState, + pub distinct_attribute: UpdateState, pub identifier: UpdateState, pub searchable_attributes: UpdateState>, pub displayed_attributes: UpdateState>, @@ -168,7 +168,7 @@ impl Default for SettingsUpdate { fn default() -> Self { Self { ranking_rules: UpdateState::Nothing, - ranking_distinct: UpdateState::Nothing, + distinct_attribute: UpdateState::Nothing, identifier: UpdateState::Nothing, searchable_attributes: UpdateState::Nothing, displayed_attributes: UpdateState::Nothing, diff --git a/meilisearch-core/src/store/main.rs b/meilisearch-core/src/store/main.rs index 2e13d52ec..a156cee4b 100644 --- a/meilisearch-core/src/store/main.rs +++ b/meilisearch-core/src/store/main.rs @@ -12,7 +12,7 @@ use crate::settings::RankingRule; const CREATED_AT_KEY: &str = "created-at"; const RANKING_RULES_KEY: &str = "ranking-rules"; -const RANKING_DISTINCT_KEY: &str = "ranking-distinct"; +const DISTINCT_ATTRIBUTE_KEY: &str = "distinct-attribute"; const STOP_WORDS_KEY: &str = "stop-words"; const SYNONYMS_KEY: &str = "synonyms"; const CUSTOMS_KEY: &str = "customs"; @@ -200,19 +200,19 @@ impl Main { self.main.delete::<_, Str>(writer, RANKING_RULES_KEY) } - pub fn ranking_distinct(&self, reader: &heed::RoTxn) -> ZResult> { - if let Some(value) = self.main.get::<_, Str, Str>(reader, RANKING_DISTINCT_KEY)? { + pub fn distinct_attribute(&self, reader: &heed::RoTxn) -> ZResult> { + if let Some(value) = self.main.get::<_, Str, Str>(reader, DISTINCT_ATTRIBUTE_KEY)? { return Ok(Some(value.to_owned())) } return Ok(None) } - pub fn put_ranking_distinct(self, writer: &mut heed::RwTxn, value: &str) -> ZResult<()> { - self.main.put::<_, Str, Str>(writer, RANKING_DISTINCT_KEY, value) + pub fn put_distinct_attribute(self, writer: &mut heed::RwTxn, value: &str) -> ZResult<()> { + self.main.put::<_, Str, Str>(writer, DISTINCT_ATTRIBUTE_KEY, value) } - pub fn delete_ranking_distinct(self, writer: &mut heed::RwTxn) -> ZResult { - self.main.delete::<_, Str>(writer, RANKING_DISTINCT_KEY) + pub fn delete_distinct_attribute(self, writer: &mut heed::RwTxn) -> ZResult { + self.main.delete::<_, Str>(writer, DISTINCT_ATTRIBUTE_KEY) } pub fn put_customs(self, writer: &mut heed::RwTxn, customs: &[u8]) -> ZResult<()> { diff --git a/meilisearch-core/src/update/settings_update.rs b/meilisearch-core/src/update/settings_update.rs index b100ba777..aa7d3f505 100644 --- a/meilisearch-core/src/update/settings_update.rs +++ b/meilisearch-core/src/update/settings_update.rs @@ -58,12 +58,12 @@ pub fn apply_settings_update( UpdateState::Nothing => (), } - match settings.ranking_distinct { + match settings.distinct_attribute { UpdateState::Update(v) => { - index.main.put_ranking_distinct(writer, &v)?; + index.main.put_distinct_attribute(writer, &v)?; }, UpdateState::Clear => { - index.main.delete_ranking_distinct(writer)?; + index.main.delete_distinct_attribute(writer)?; }, UpdateState::Nothing => (), } diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index a12d226c8..5caa765f5 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -82,7 +82,7 @@ pub fn load_routes(app: &mut tide::Server) { .post(|ctx| into_response(setting::update_rules(ctx))) .delete(|ctx| into_response(setting::delete_rules(ctx))); - app.at("/indexes/:index/settings/ranking-distinct") + app.at("/indexes/:index/settings/distinct-attribute") .get(|ctx| into_response(setting::get_distinct(ctx))) .post(|ctx| into_response(setting::update_distinct(ctx))) .delete(|ctx| into_response(setting::delete_distinct(ctx))); diff --git a/meilisearch-http/src/routes/setting.rs b/meilisearch-http/src/routes/setting.rs index b70636217..f106a69ea 100644 --- a/meilisearch-http/src/routes/setting.rs +++ b/meilisearch-http/src/routes/setting.rs @@ -50,7 +50,7 @@ pub async fn get_all(ctx: Request) -> SResult { Some(rules) => Some(rules.iter().map(|r| r.to_string()).collect()), None => None, }; - let ranking_distinct = index.main.ranking_distinct(&reader)?; + let distinct_attribute = index.main.distinct_attribute(&reader)?; let schema = index.main.schema(&reader)?; @@ -81,7 +81,7 @@ pub async fn get_all(ctx: Request) -> SResult { let settings = Settings { ranking_rules: Some(ranking_rules), - ranking_distinct: Some(ranking_distinct), + distinct_attribute: Some(distinct_attribute), searchable_attributes, displayed_attributes, stop_words: Some(stop_words), @@ -96,7 +96,7 @@ pub async fn get_all(ctx: Request) -> SResult { #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct UpdateSettings { pub ranking_rules: Option>, - pub ranking_distinct: Option, + pub distinct_attribute: Option, pub identifier: Option, pub searchable_attributes: Option>, pub displayed_attributes: Option>, @@ -114,7 +114,7 @@ pub async fn update_all(mut ctx: Request) -> SResult { let settings = Settings { ranking_rules: Some(settings_update.ranking_rules), - ranking_distinct: Some(settings_update.ranking_distinct), + distinct_attribute: Some(settings_update.distinct_attribute), searchable_attributes: Some(settings_update.searchable_attributes), displayed_attributes: Some(settings_update.displayed_attributes), stop_words: Some(settings_update.stop_words), @@ -138,7 +138,7 @@ pub async fn delete_all(ctx: Request) -> SResult { let settings = SettingsUpdate { ranking_rules: UpdateState::Clear, - ranking_distinct: UpdateState::Clear, + distinct_attribute: UpdateState::Clear, identifier: UpdateState::Clear, searchable_attributes: UpdateState::Clear, displayed_attributes: UpdateState::Clear, @@ -214,22 +214,22 @@ pub async fn get_distinct(ctx: Request) -> SResult { let db = &ctx.state().db; let reader = db.main_read_txn()?; - let ranking_distinct = index.main.ranking_distinct(&reader)?; + let distinct_attribute = index.main.distinct_attribute(&reader)?; Ok(tide::Response::new(200) - .body_json(&ranking_distinct) + .body_json(&distinct_attribute) .unwrap()) } pub async fn update_distinct(mut ctx: Request) -> SResult { ctx.is_allowed(Private)?; let index = ctx.index()?; - let ranking_distinct: Option = + let distinct_attribute: Option = ctx.body_json().await.map_err(ResponseError::bad_request)?; let db = &ctx.state().db; let settings = Settings { - ranking_distinct: Some(ranking_distinct), + distinct_attribute: Some(distinct_attribute), ..Settings::default() }; @@ -248,7 +248,7 @@ pub async fn delete_distinct(ctx: Request) -> SResult { let mut writer = db.update_write_txn()?; let settings = SettingsUpdate { - ranking_distinct: UpdateState::Clear, + distinct_attribute: UpdateState::Clear, ..SettingsUpdate::default() };