Search for closest non-stop words in proximity criteria

This commit is contained in:
Samyak S Sarnayak 2022-10-13 22:47:41 +05:30
parent 709ab3c14c
commit 3e190503e6
No known key found for this signature in database
GPG Key ID: 365873F2F0C6153B

View File

@ -187,14 +187,15 @@ fn resolve_candidates<'t>(
Phrase(words) => { Phrase(words) => {
if proximity == 0 { if proximity == 0 {
let most_left = words let most_left = words
.first() .iter()
.map(|o| o.as_ref()) .filter_map(|o| o.as_ref())
.flatten() .next()
.map(|w| Query { prefix: false, kind: QueryKind::exact(w.clone()) }); .map(|w| Query { prefix: false, kind: QueryKind::exact(w.clone()) });
let most_right = words let most_right = words
.last() .iter()
.map(|o| o.as_ref()) .rev()
.flatten() .filter_map(|o| o.as_ref())
.next()
.map(|w| Query { prefix: false, kind: QueryKind::exact(w.clone()) }); .map(|w| Query { prefix: false, kind: QueryKind::exact(w.clone()) });
match (most_left, most_right) { match (most_left, most_right) {