From 098ab594eb156f5ba34ee4db81893f4e2c146b1f Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 19 Mar 2024 17:32:32 +0100 Subject: [PATCH] A score of 0.0 is now lesser than a sort result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handles the niche case 🐩 in the hybrid search where: 1. a sort ranking rule is the first rule. 2. the keyword search is skipped at the first rule. 3. the semantic search is not skipped at the first rule. Previously, we would have the skipped search winning, whereas we want the non skipped one winning. --- milli/src/search/hybrid.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/milli/src/search/hybrid.rs b/milli/src/search/hybrid.rs index 47ac5f46b..a8b7f0fcf 100644 --- a/milli/src/search/hybrid.rs +++ b/milli/src/search/hybrid.rs @@ -50,8 +50,12 @@ fn compare_scores( order => return order, } } - (Some(ScoreValue::Score(_)), Some(_)) => return Ordering::Greater, - (Some(_), Some(ScoreValue::Score(_))) => return Ordering::Less, + (Some(ScoreValue::Score(x)), Some(_)) => { + return if x == 0. { Ordering::Less } else { Ordering::Greater } + } + (Some(_), Some(ScoreValue::Score(x))) => { + return if x == 0. { Ordering::Greater } else { Ordering::Less } + } // if we have this, we're bad (Some(ScoreValue::GeoSort(_)), Some(ScoreValue::Sort(_))) | (Some(ScoreValue::Sort(_)), Some(ScoreValue::GeoSort(_))) => {