search: levenshtein2 for word bigger than 8 chars

This commit is contained in:
Clément Renault 2018-04-22 23:11:23 +02:00
parent b729c76bce
commit 55bda1cd71
2 changed files with 8 additions and 1 deletions

View File

@ -18,3 +18,6 @@ tokio-minihttp = { git = "https://github.com/tokio-rs/tokio-minihttp.git" }
tokio-proto = "0.1" tokio-proto = "0.1"
tokio-service = "0.1" tokio-service = "0.1"
url = "1.7" url = "1.7"
[profile.release]
lto = true

View File

@ -54,7 +54,11 @@ impl Service for MainService {
if let Some((_, key)) = url.query_pairs().find(|&(ref k, _)| k == "q") { if let Some((_, key)) = url.query_pairs().find(|&(ref k, _)| k == "q") {
let key = key.to_lowercase(); let key = key.to_lowercase();
let lev = Levenshtein::new(&key, 2).unwrap(); let lev = if key.len() <= 8 {
Levenshtein::new(&key, 1).unwrap()
} else {
Levenshtein::new(&key, 2).unwrap()
};
let mut body = String::new(); let mut body = String::new();
body.push_str("<html><body>"); body.push_str("<html><body>");