mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
Fix the maximum_proximity function
This commit is contained in:
parent
9bc9b36645
commit
ae4a237e58
@ -153,8 +153,14 @@ fn query_docids(ctx: &dyn Context, query: &Query) -> anyhow::Result<RoaringBitma
|
||||
}
|
||||
|
||||
fn query_pair_proximity_docids(ctx: &dyn Context, left: &Query, right: &Query, proximity: u8) -> anyhow::Result<RoaringBitmap> {
|
||||
let prefix = right.prefix;
|
||||
if proximity >= 8 {
|
||||
let mut candidates = query_docids(ctx, left)?;
|
||||
let right_candidates = query_docids(ctx, right)?;
|
||||
candidates.intersect_with(&right_candidates);
|
||||
return Ok(candidates);
|
||||
}
|
||||
|
||||
let prefix = right.prefix;
|
||||
match (&left.kind, &right.kind) {
|
||||
(QueryKind::Exact { word: left, .. }, QueryKind::Exact { word: right, .. }) => {
|
||||
if prefix && ctx.in_prefix_cache(&right) {
|
||||
|
@ -546,7 +546,10 @@ pub fn maximum_proximity(operation: &Operation) -> usize {
|
||||
use Operation::{Or, And, Query, Consecutive};
|
||||
match operation {
|
||||
Or(_, ops) => ops.iter().map(maximum_proximity).max().unwrap_or(0),
|
||||
And(ops) => ops.len().saturating_sub(1) * 8,
|
||||
And(ops) => {
|
||||
ops.iter().map(maximum_proximity).sum::<usize>()
|
||||
+ ops.len().saturating_sub(1) * 7
|
||||
},
|
||||
Query(_) | Consecutive(_) => 0,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user