From 5ce4d5f55267218c458c3c222e086c8979fa3179 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 11 Apr 2024 18:54:03 +0200 Subject: [PATCH] Fix result logic --- milli/src/search/recommend.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/milli/src/search/recommend.rs b/milli/src/search/recommend.rs index fb9ce56f7..ccf8a5787 100644 --- a/milli/src/search/recommend.rs +++ b/milli/src/search/recommend.rs @@ -171,7 +171,14 @@ impl<'a> Recommend<'a> { let mut document_scores = Vec::with_capacity(self.limit); // skip offset +1 to skip the target document that is normally returned - for (docid, distance) in results.into_iter().skip(self.offset + 1) { + for (docid, distance) in results.into_iter().skip(self.offset) { + if documents_ids.len() == self.limit { + break; + } + if id == docid { + continue; + } + documents_ids.push(docid); let score = 1.0 - distance;