From 8970246bc4ddab7fc82a08e6043fe2859f5af243 Mon Sep 17 00:00:00 2001 From: many Date: Mon, 22 Nov 2021 18:16:54 +0100 Subject: [PATCH] Sort positions before iterating over them during word pair proximity extraction --- .../extract/extract_word_pair_proximity_docids.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs b/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs index 982799a65..f3667694a 100644 --- a/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs +++ b/milli/src/update/index_documents/extract/extract_word_pair_proximity_docids.rs @@ -53,7 +53,9 @@ pub fn extract_word_pair_proximity_docids( } let word = word.to_string(); - let mut iter = read_u32_ne_bytes(value).collect::>().into_iter(); + let mut positions: Vec<_> = read_u32_ne_bytes(value).collect(); + positions.sort_unstable(); + let mut iter = positions.into_iter(); if let Some(position) = iter.next() { document_word_positions_heap.push(PeekedWordPosition { word, position, iter }); }