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 4f50733fd..3695b3f82 100644 Binary files a/meilisearch/tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump and b/meilisearch/tests/assets/v6_v1.6.0_use_deactivated_experimental_setting.dump differ 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,