From d6868dbd4747a07812899b0967ae6d87351fae9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Wed, 7 Jun 2023 11:50:58 +0200 Subject: [PATCH] Reduce the maximum word proximity from 8 to 4 --- milli/src/proximity.rs | 2 +- milli/src/search/new/ranking_rule_graph/proximity/build.rs | 3 ++- .../extract/extract_word_pair_proximity_docids.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/milli/src/proximity.rs b/milli/src/proximity.rs index 62f490119..8261015a3 100644 --- a/milli/src/proximity.rs +++ b/milli/src/proximity.rs @@ -2,7 +2,7 @@ use std::cmp; use crate::{relative_from_absolute_position, Position}; -pub const MAX_DISTANCE: u32 = 8; +pub const MAX_DISTANCE: u32 = 4; pub fn index_proximity(lhs: u32, rhs: u32) -> u32 { if lhs <= rhs { diff --git a/milli/src/search/new/ranking_rule_graph/proximity/build.rs b/milli/src/search/new/ranking_rule_graph/proximity/build.rs index 660d59b3e..deb56af36 100644 --- a/milli/src/search/new/ranking_rule_graph/proximity/build.rs +++ b/milli/src/search/new/ranking_rule_graph/proximity/build.rs @@ -1,6 +1,7 @@ #![allow(clippy::too_many_arguments)] use super::ProximityCondition; +use crate::proximity::MAX_DISTANCE; use crate::search::new::interner::{DedupInterner, Interned}; use crate::search::new::query_term::LocatedQueryTermSubset; use crate::search::new::SearchContext; @@ -47,7 +48,7 @@ pub fn build_edges( } conditions.push(( - (7 + right_ngram_length) as u32, + MAX_DISTANCE - 1 + right_ngram_length as u32, conditions_interner.insert(ProximityCondition::Term { term: right_term.clone() }), )); 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 6707fc268..6a0012b4a 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 @@ -91,7 +91,7 @@ fn document_word_positions_into_sorter( while !word_positions_heap.is_empty() { while let Some(peeked_word_position) = word_positions_heap.pop() { ordered_peeked_word_positions.push(peeked_word_position); - if ordered_peeked_word_positions.len() == 7 { + if ordered_peeked_word_positions.len() == MAX_DISTANCE as usize - 1 { break; } }