From 856c5c4214e54fe9c98758051ec585f9a41e1a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 31 Dec 2019 13:07:05 +0100 Subject: [PATCH] Fix group offset computing --- meilisearch-core/src/bucket_sort.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/meilisearch-core/src/bucket_sort.rs b/meilisearch-core/src/bucket_sort.rs index 07fc13779..a3c4b89af 100644 --- a/meilisearch-core/src/bucket_sort.rs +++ b/meilisearch-core/src/bucket_sort.rs @@ -548,15 +548,16 @@ fn fetch_matches<'txn, 'tag>( for group in postings_list_view.linear_group_by_key(|di| di.document_id) { let document_id = group[0].document_id; - if query_index != 0 { - if !documents_ids.contains(&document_id) { continue } - } else { - documents_ids.insert(document_id); + if query_index != 0 && !documents_ids.contains(&document_id) { + offset += group.len(); + continue } + documents_ids.insert(document_id); postings_lists_length += group.len(); - let posting_list_index = arena.add(postings_list_view.range(offset, group.len())); + let range = postings_list_view.range(offset, group.len()); + let posting_list_index = arena.add(range); let bare_match = BareMatch { document_id, query_index: query_index as u16, @@ -565,6 +566,7 @@ fn fetch_matches<'txn, 'tag>( postings_list: posting_list_index, }; + total_postings_lists.push(bare_match); offset += group.len(); } @@ -611,15 +613,16 @@ fn fetch_matches<'txn, 'tag>( for group in postings_list_view.linear_group_by_key(|di| di.document_id) { let document_id = group[0].document_id; - if query_index != 0 { - if !documents_ids.contains(&document_id) { continue } - } else { - documents_ids.insert(document_id); + if query_index != 0 && !documents_ids.contains(&document_id) { + offset += group.len(); + continue } + documents_ids.insert(document_id); postings_lists_length += group.len(); - let posting_list_index = arena.add(postings_list_view.range(offset, group.len())); + let range = postings_list_view.range(offset, group.len()); + let posting_list_index = arena.add(range); let bare_match = BareMatch { document_id, query_index: query_index as u16,