From fae118a46ba23da5aed9f4436e16ba7677ecbb84 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 18 Mar 2022 12:37:27 +0100 Subject: Improve fuzzy search (#279) * Add SearchMode fzf. Add a new search mode "fzf" that tries to mimic the search syntax of https://github.com/junegunn/fzf#search-syntax This search mode splits the query into terms where each term is matched individually. Terms can have operators like prefix, suffix, exact match only and can be inverted. Additionally, smart-case matching is performed: if a term contains a non-lowercase letter the match will be case-sensitive. * PR feedback. - Use SearchMode::Fuzzy instead of SearchMode::Fzf - update docs - re-order tests so previous fuzzy tests come first, add more tests for each operator * PR comments: remove named arguments, match expression * PR comments: macro -> async func --- atuin-client/src/ordering.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'atuin-client/src/ordering.rs') diff --git a/atuin-client/src/ordering.rs b/atuin-client/src/ordering.rs index b6051d15..0bb12c6a 100644 --- a/atuin-client/src/ordering.rs +++ b/atuin-client/src/ordering.rs @@ -17,6 +17,7 @@ where let mut r = res.clone(); let qvec = &query.chars().collect(); r.sort_by_cached_key(|h| { + // TODO for fzf search we should sum up scores for each matched term let (from, to) = match minspan::span(qvec, &(f(h).chars().collect())) { Some(x) => x, // this is a little unfortunate: when we are asked to match a query that is found nowhere, -- cgit v1.3.1