mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08:00
Reduce maximum indexed proximity for word pairs
This commit is contained in:
parent
daa4138df9
commit
17f6d65840
@ -2,7 +2,7 @@ use std::cmp;
|
|||||||
|
|
||||||
use crate::{relative_from_absolute_position, Position};
|
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 {
|
pub fn index_proximity(lhs: u32, rhs: u32) -> u32 {
|
||||||
if lhs <= rhs {
|
if lhs <= rhs {
|
||||||
|
@ -6,6 +6,8 @@ use crate::search::new::query_term::LocatedQueryTermSubset;
|
|||||||
use crate::search::new::SearchContext;
|
use crate::search::new::SearchContext;
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
||||||
|
const MAX_PROX: usize = crate::proximity::MAX_DISTANCE as usize;
|
||||||
|
|
||||||
pub fn build_edges(
|
pub fn build_edges(
|
||||||
_ctx: &mut SearchContext,
|
_ctx: &mut SearchContext,
|
||||||
conditions_interner: &mut DedupInterner<ProximityCondition>,
|
conditions_interner: &mut DedupInterner<ProximityCondition>,
|
||||||
@ -35,7 +37,7 @@ pub fn build_edges(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut conditions = vec![];
|
let mut conditions = vec![];
|
||||||
for cost in right_ngram_length..(7 + right_ngram_length) {
|
for cost in right_ngram_length..(MAX_PROX + right_ngram_length) {
|
||||||
conditions.push((
|
conditions.push((
|
||||||
cost as u32,
|
cost as u32,
|
||||||
conditions_interner.insert(ProximityCondition::Uninit {
|
conditions_interner.insert(ProximityCondition::Uninit {
|
||||||
@ -47,7 +49,7 @@ pub fn build_edges(
|
|||||||
}
|
}
|
||||||
|
|
||||||
conditions.push((
|
conditions.push((
|
||||||
(7 + right_ngram_length) as u32,
|
(MAX_PROX + right_ngram_length) as u32,
|
||||||
conditions_interner.insert(ProximityCondition::Term { term: right_term.clone() }),
|
conditions_interner.insert(ProximityCondition::Term { term: right_term.clone() }),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ fn document_word_positions_into_sorter(
|
|||||||
while !word_positions_heap.is_empty() {
|
while !word_positions_heap.is_empty() {
|
||||||
while let Some(peeked_word_position) = word_positions_heap.pop() {
|
while let Some(peeked_word_position) = word_positions_heap.pop() {
|
||||||
ordered_peeked_word_positions.push(peeked_word_position);
|
ordered_peeked_word_positions.push(peeked_word_position);
|
||||||
if ordered_peeked_word_positions.len() == 7 {
|
if ordered_peeked_word_positions.len() == (MAX_DISTANCE - 1) as usize {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user