From 43989fe2e4977736ec3685c6516f86b172298479 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Tue, 3 Oct 2023 12:02:16 +0200 Subject: [PATCH] Reduce porximity range from 7 to 3 --- milli/src/proximity.rs | 2 +- milli/src/search/new/ranking_rule_graph/proximity/build.rs | 5 +++-- 2 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 a5c0b07cb..d9d1a77ae 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; @@ -35,7 +36,7 @@ pub fn build_edges( } let mut conditions = vec![]; - for cost in right_ngram_max..(7 + right_ngram_max) { + for cost in right_ngram_max..(((MAX_DISTANCE as usize) - 1) + right_ngram_max) { conditions.push(( cost as u32, conditions_interner.insert(ProximityCondition::Uninit { @@ -47,7 +48,7 @@ pub fn build_edges( } conditions.push(( - (7 + right_ngram_max) as u32, + ((MAX_DISTANCE - 1) + (right_ngram_max as u32)), conditions_interner.insert(ProximityCondition::Term { term: right_term.clone() }), ));