Tweak FTS query
Attempt to smartly use NEAR searches and prefix searches depending on input. This is hopefully a good idea
This commit is contained in:
parent
8104430701
commit
59c11897b2
1 changed files with 12 additions and 1 deletions
13
src/state.rs
13
src/state.rs
|
@ -316,7 +316,18 @@ impl State {
|
|||
format!("\"{}\"", src.replace('\"', "\"\""))
|
||||
}
|
||||
|
||||
let query = fts_quote(&query_string);
|
||||
let words = query_string
|
||||
.split_whitespace()
|
||||
.map(fts_quote)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let query = if words.len() > 1 {
|
||||
format!("NEAR({})", words.join(" "))
|
||||
} else if words.len() == 1 {
|
||||
format!("{}*", words[0])
|
||||
} else {
|
||||
"\"\"".to_owned()
|
||||
};
|
||||
|
||||
Ok(
|
||||
sql::<(Text, Text, Text)>(
|
||||
|
|
Loading…
Reference in a new issue