13 lines
368 B
Rust
13 lines
368 B
Rust
pub fn fts_query(q: &str) -> Option<String> {
|
|
let terms: Vec<String> = q
|
|
.split_whitespace()
|
|
.map(|t| t.trim_matches(['"', '\'', '*', '(', ')', ':', '[', ']']))
|
|
.filter(|t| !t.is_empty())
|
|
.map(|t| format!("\"{}\"", t))
|
|
.collect();
|
|
if terms.is_empty() {
|
|
None
|
|
} else {
|
|
Some(terms.join(" AND "))
|
|
}
|
|
} |