Struct simsearch::SearchOptions
source · pub struct SearchOptions { /* private fields */ }
Expand description
Options and flags that configuring the search engine.
§Examples
use simsearch::{SearchOptions, SimSearch};
let mut engine: SimSearch<usize> = SimSearch::new_with(
SearchOptions::new().case_sensitive(true));
Implementations§
source§impl SearchOptions
impl SearchOptions
sourcepub fn case_sensitive(self, case_sensitive: bool) -> Self
pub fn case_sensitive(self, case_sensitive: bool) -> Self
Sets whether search engine is case sensitive or not.
Defaults to false
.
sourcepub fn stop_whitespace(self, stop_whitespace: bool) -> Self
pub fn stop_whitespace(self, stop_whitespace: bool) -> Self
Sets the whether search engine splits tokens on whitespace or not. The whitespace here includes tab, returns and so forth.
See also std::str::split_whitespace()
.
Defaults to true
.
sourcepub fn stop_words(self, stop_words: Vec<String>) -> Self
pub fn stop_words(self, stop_words: Vec<String>) -> Self
Sets the custom token stop word.
This option enables tokenizer to split contents and search words by the extra list of custom stop words.
Defaults to &[]
.
§Examples
use simsearch::{SearchOptions, SimSearch};
let mut engine: SimSearch<usize> = SimSearch::new_with(
SearchOptions::new().stop_words(vec!["/".to_string(), "\\".to_string()]));
engine.insert(1, "the old/man/and/the sea");
let results = engine.search("old");
assert_eq!(results, &[1]);
sourcepub fn threshold(self, threshold: f64) -> Self
pub fn threshold(self, threshold: f64) -> Self
Sets the threshold for search scoring.
Search results will be sorted by their Jaro winkler similarity scores. Scores ranges from 0 to 1 where the 1 indicates the most relevant. Only the entries with scores greater than the threshold will be returned.
Defaults to 0.8
.
sourcepub fn levenshtein(self, levenshtein: bool) -> Self
pub fn levenshtein(self, levenshtein: bool) -> Self
Sets whether Levenshtein distance, which is SIMD-accelerated, should be used instead of the default Jaro-Winkler distance.
The implementation of Levenshtein distance is very fast but cannot handle Unicode strings, unlike the default Jaro-Winkler distance. The strings are treated as byte slices with Levenshtein distance, which means that the calculated score may be incorrectly lower for Unicode strings, where each character is represented with multiple bytes.
Defaults to false
.
Trait Implementations§
source§impl Clone for SearchOptions
impl Clone for SearchOptions
source§fn clone(&self) -> SearchOptions
fn clone(&self) -> SearchOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more