From 1df5b8712bb0932e1dc524af545ec445b2e2af6e Mon Sep 17 00:00:00 2001 From: many Date: Wed, 29 Sep 2021 14:41:56 +0200 Subject: [PATCH 1/3] Hotfix meilisearch#1707 --- milli/src/search/criteria/attribute.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/milli/src/search/criteria/attribute.rs b/milli/src/search/criteria/attribute.rs index 6e0bb40d5..468f2ce32 100644 --- a/milli/src/search/criteria/attribute.rs +++ b/milli/src/search/criteria/attribute.rs @@ -192,7 +192,10 @@ impl<'t, 'q> WordLevelIterator<'t, 'q> { in_prefix_cache: bool, ) -> heed::Result> { match ctx.word_position_last_level(&word, in_prefix_cache)? { - Some(level) => { + Some(_) => { + // HOTFIX Meilisearch#1707: it is better to only iterate over the level 0. + // A cleaner fix will be implemented soon. + let level = TreeLevel::min_value(); let interval_size = LEVEL_EXPONENTIATION_BASE.pow(Into::::into(level) as u32); let inner = ctx.word_position_iterator(&word, level, in_prefix_cache, None, None)?; @@ -528,10 +531,10 @@ impl<'t, 'q> Branch<'t, 'q> { fn cmp(&self, other: &Self) -> Ordering { let self_rank = self.compute_rank(); let other_rank = other.compute_rank(); - let left_cmp = self_rank.cmp(&other_rank).reverse(); + let left_cmp = self_rank.cmp(&other_rank); // on level: lower is better, // we want to dig faster into levels on interesting branches. - let level_cmp = self.tree_level.cmp(&other.tree_level).reverse(); + let level_cmp = self.tree_level.cmp(&other.tree_level); left_cmp.then(level_cmp).then(self.last_result.2.len().cmp(&other.last_result.2.len())) } From 7ad0214089f7c2a1a469c2e25e727f819040cd81 Mon Sep 17 00:00:00 2001 From: Many Date: Wed, 29 Sep 2021 14:49:41 +0200 Subject: [PATCH 2/3] Update milli/src/search/criteria/attribute.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Renault --- milli/src/search/criteria/attribute.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/milli/src/search/criteria/attribute.rs b/milli/src/search/criteria/attribute.rs index 468f2ce32..8703bb268 100644 --- a/milli/src/search/criteria/attribute.rs +++ b/milli/src/search/criteria/attribute.rs @@ -194,7 +194,6 @@ impl<'t, 'q> WordLevelIterator<'t, 'q> { match ctx.word_position_last_level(&word, in_prefix_cache)? { Some(_) => { // HOTFIX Meilisearch#1707: it is better to only iterate over the level 0. - // A cleaner fix will be implemented soon. let level = TreeLevel::min_value(); let interval_size = LEVEL_EXPONENTIATION_BASE.pow(Into::::into(level) as u32); let inner = From 2e49230ca24eb4fa455df79fc33c864169dc0992 Mon Sep 17 00:00:00 2001 From: Many Date: Wed, 29 Sep 2021 14:49:45 +0200 Subject: [PATCH 3/3] Update milli/src/search/criteria/attribute.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Renault --- milli/src/search/criteria/attribute.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/milli/src/search/criteria/attribute.rs b/milli/src/search/criteria/attribute.rs index 8703bb268..5eb1311a1 100644 --- a/milli/src/search/criteria/attribute.rs +++ b/milli/src/search/criteria/attribute.rs @@ -193,7 +193,7 @@ impl<'t, 'q> WordLevelIterator<'t, 'q> { ) -> heed::Result> { match ctx.word_position_last_level(&word, in_prefix_cache)? { Some(_) => { - // HOTFIX Meilisearch#1707: it is better to only iterate over the level 0. + // HOTFIX Meilisearch#1707: it is better to only iterate over level 0 for performances reasons. let level = TreeLevel::min_value(); let interval_size = LEVEL_EXPONENTIATION_BASE.pow(Into::::into(level) as u32); let inner =