From 6425996e3641c4e040c9e73666586ee1cb5ff72f Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Thu, 14 Dec 2023 16:31:00 +0100 Subject: [PATCH] Change the naming of attributeScale and wordScale into byAttribute and byWord --- meilisearch-types/src/settings.rs | 12 +++--- ..._use_deactivated_experimental_setting.dump | Bin 1522 -> 1535 bytes meilisearch/tests/dumps/mod.rs | 2 +- .../tests/settings/proximity_settings.rs | 10 ++--- milli/src/proximity.rs | 4 +- milli/src/search/new/db_cache.rs | 40 +++++++++--------- .../src/update/index_documents/extract/mod.rs | 2 +- 7 files changed, 34 insertions(+), 36 deletions(-) diff --git a/meilisearch-types/src/settings.rs b/meilisearch-types/src/settings.rs index 487354b8e..f59297b59 100644 --- a/meilisearch-types/src/settings.rs +++ b/meilisearch-types/src/settings.rs @@ -703,23 +703,23 @@ impl From for Criterion { #[serde(deny_unknown_fields, rename_all = "camelCase")] #[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)] pub enum ProximityPrecisionView { - WordScale, - AttributeScale, + ByWord, + ByAttribute, } impl From for ProximityPrecisionView { fn from(value: ProximityPrecision) -> Self { match value { - ProximityPrecision::WordScale => ProximityPrecisionView::WordScale, - ProximityPrecision::AttributeScale => ProximityPrecisionView::AttributeScale, + ProximityPrecision::ByWord => ProximityPrecisionView::ByWord, + ProximityPrecision::ByAttribute => ProximityPrecisionView::ByAttribute, } } } impl From for ProximityPrecision { fn from(value: ProximityPrecisionView) -> Self { match value { - ProximityPrecisionView::WordScale => ProximityPrecision::WordScale, - ProximityPrecisionView::AttributeScale => ProximityPrecision::AttributeScale, + ProximityPrecisionView::ByWord => ProximityPrecision::ByWord, + ProximityPrecisionView::ByAttribute => ProximityPrecision::ByAttribute, } } } diff --git a/meilisearch/tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump b/meilisearch/tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump index 4f50733fd179e3b36e5a36fb822783deaaa9209f..3695b3f82065b34ae7f255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Er4;^nXzr_6QjL zbL0R$CI83w+Wem;Q0o8Rf*1U3Zr}m`kD}f4A8}j%uMt%7e^hx2A2yQ#U~W_a&V!v7 zQN(%7<1zqd;$C&Ec>DgCFd9UlL_Ugn!qti!0`DbB+`ZGB+quW&y z4e)GJsrv+`G=b3URh?+5sg?SE6v-l0WuDxzTBtj^jANmN-eoI&!0PAX3pnf#PcVI# zXM)Yr!#dFUJCuNbe^3XdWEg~pbzqW$JmdsxI&ju?P@Yj9pMPMcUO!CH($@~ diff --git a/meilisearch/tests/dumps/mod.rs b/meilisearch/tests/dumps/mod.rs index cb61d5e29..b06db6f27 100644 --- a/meilisearch/tests/dumps/mod.rs +++ b/meilisearch/tests/dumps/mod.rs @@ -1877,7 +1877,7 @@ async fn import_dump_v6_containing_experimental_features() { "dictionary": [], "synonyms": {}, "distinctAttribute": null, - "proximityPrecision": "attributeScale", + "proximityPrecision": "byAttribute", "typoTolerance": { "enabled": true, "minWordSizeForTypos": { diff --git a/meilisearch/tests/settings/proximity_settings.rs b/meilisearch/tests/settings/proximity_settings.rs index 83f6c65b5..8b206ded4 100644 --- a/meilisearch/tests/settings/proximity_settings.rs +++ b/meilisearch/tests/settings/proximity_settings.rs @@ -34,7 +34,7 @@ async fn attribute_scale_search() { let (response, code) = index .update_settings(json!({ - "proximityPrecision": "attributeScale", + "proximityPrecision": "byAttribute", "rankingRules": ["words", "typo", "proximity"], })) .await; @@ -107,7 +107,7 @@ async fn attribute_scale_phrase_search() { let (_response, _code) = index .update_settings(json!({ - "proximityPrecision": "attributeScale", + "proximityPrecision": "byAttribute", "rankingRules": ["words", "typo", "proximity"], })) .await; @@ -176,7 +176,7 @@ async fn word_scale_set_and_reset() { // Set and reset the setting ensuring the swap between the 2 settings is applied. let (_response, _code) = index .update_settings(json!({ - "proximityPrecision": "attributeScale", + "proximityPrecision": "byAttribute", "rankingRules": ["words", "typo", "proximity"], })) .await; @@ -184,7 +184,7 @@ async fn word_scale_set_and_reset() { let (_response, _code) = index .update_settings(json!({ - "proximityPrecision": "wordScale", + "proximityPrecision": "byWord", "rankingRules": ["words", "typo", "proximity"], })) .await; @@ -290,7 +290,7 @@ async fn attribute_scale_default_ranking_rules() { let (response, code) = index .update_settings(json!({ - "proximityPrecision": "attributeScale" + "proximityPrecision": "byAttribute" })) .await; assert_eq!("202", code.as_str(), "{:?}", response); diff --git a/milli/src/proximity.rs b/milli/src/proximity.rs index 2745527c1..ce47d7775 100644 --- a/milli/src/proximity.rs +++ b/milli/src/proximity.rs @@ -32,6 +32,6 @@ pub fn path_proximity(path: &[Position]) -> u32 { #[serde(rename_all = "camelCase")] pub enum ProximityPrecision { #[default] - WordScale, - AttributeScale, + ByWord, + ByAttribute, } diff --git a/milli/src/search/new/db_cache.rs b/milli/src/search/new/db_cache.rs index 76948f1ed..62c921a1d 100644 --- a/milli/src/search/new/db_cache.rs +++ b/milli/src/search/new/db_cache.rs @@ -299,9 +299,9 @@ impl<'ctx> SearchContext<'ctx> { proximity: u8, ) -> Result> { match self.index.proximity_precision(self.txn)?.unwrap_or_default() { - ProximityPrecision::AttributeScale => { + ProximityPrecision::ByAttribute => { // Force proximity to 0 because: - // in AttributeScale, there are only 2 possible distances: + // in ByAttribute, there are only 2 possible distances: // 1. words in same attribute: in that the DB contains (0, word1, word2) // 2. words in different attributes: no DB entry for these two words. let proximity = 0; @@ -345,19 +345,17 @@ impl<'ctx> SearchContext<'ctx> { Ok(docids) } - ProximityPrecision::WordScale => { - DatabaseCache::get_value::<_, _, CboRoaringBitmapCodec>( - self.txn, - (proximity, word1, word2), - &( - proximity, - self.word_interner.get(word1).as_str(), - self.word_interner.get(word2).as_str(), - ), - &mut self.db_cache.word_pair_proximity_docids, - self.index.word_pair_proximity_docids.remap_data_type::(), - ) - } + ProximityPrecision::ByWord => DatabaseCache::get_value::<_, _, CboRoaringBitmapCodec>( + self.txn, + (proximity, word1, word2), + &( + proximity, + self.word_interner.get(word1).as_str(), + self.word_interner.get(word2).as_str(), + ), + &mut self.db_cache.word_pair_proximity_docids, + self.index.word_pair_proximity_docids.remap_data_type::(), + ), } } @@ -368,10 +366,10 @@ impl<'ctx> SearchContext<'ctx> { proximity: u8, ) -> Result> { match self.index.proximity_precision(self.txn)?.unwrap_or_default() { - ProximityPrecision::AttributeScale => Ok(self + ProximityPrecision::ByAttribute => Ok(self .get_db_word_pair_proximity_docids(word1, word2, proximity)? .map(|d| d.len())), - ProximityPrecision::WordScale => { + ProximityPrecision::ByWord => { DatabaseCache::get_value::<_, _, CboRoaringBitmapLenCodec>( self.txn, (proximity, word1, word2), @@ -394,9 +392,9 @@ impl<'ctx> SearchContext<'ctx> { mut proximity: u8, ) -> Result> { let proximity_precision = self.index.proximity_precision(self.txn)?.unwrap_or_default(); - if proximity_precision == ProximityPrecision::AttributeScale { + if proximity_precision == ProximityPrecision::ByAttribute { // Force proximity to 0 because: - // in AttributeScale, there are only 2 possible distances: + // in ByAttribute, there are only 2 possible distances: // 1. words in same attribute: in that the DB contains (0, word1, word2) // 2. words in different attributes: no DB entry for these two words. proximity = 0; @@ -408,7 +406,7 @@ impl<'ctx> SearchContext<'ctx> { docids.clone() } else { let prefix_docids = match proximity_precision { - ProximityPrecision::AttributeScale => { + ProximityPrecision::ByAttribute => { // Compute the distance at the attribute level and store it in the cache. let fids = if let Some(fids) = self.index.searchable_fields_ids(self.txn)? { fids @@ -429,7 +427,7 @@ impl<'ctx> SearchContext<'ctx> { } prefix_docids } - ProximityPrecision::WordScale => { + ProximityPrecision::ByWord => { // compute docids using prefix iter and store the result in the cache. let key = U8StrStrCodec::bytes_encode(&( proximity, diff --git a/milli/src/update/index_documents/extract/mod.rs b/milli/src/update/index_documents/extract/mod.rs index 57f349894..2dc3f2efe 100644 --- a/milli/src/update/index_documents/extract/mod.rs +++ b/milli/src/update/index_documents/extract/mod.rs @@ -152,7 +152,7 @@ pub(crate) fn data_from_obkv_documents( }); } - if proximity_precision == ProximityPrecision::WordScale { + if proximity_precision == ProximityPrecision::ByWord { spawn_extraction_task::<_, _, Vec>>>( docid_word_positions_chunks.clone(), indexer,