review changes

This commit is contained in:
ad hoc 2022-05-24 14:15:33 +02:00
parent 69dc4de80f
commit 25fc576696
No known key found for this signature in database
GPG Key ID: 4F00A782990CC643

View File

@ -193,14 +193,13 @@ impl<'a> QueryTreeBuilder<'a> {
/// Create a `QueryTreeBuilder` from a heed ReadOnly transaction `rtxn`
/// and an Index `index`.
pub fn new(rtxn: &'a heed::RoTxn<'a>, index: &'a Index) -> Result<Self> {
let exact_words = index.exact_words(rtxn)?;
Ok(Self {
rtxn,
index,
optional_words: true,
authorize_typos: true,
words_limit: None,
exact_words,
exact_words: index.exact_words(rtxn)?,
})
}
@ -292,7 +291,7 @@ pub struct TypoConfig<'a> {
/// Return the `QueryKind` of a word depending on `authorize_typos`
/// and the provided word length.
fn typos<'a>(word: String, authorize_typos: bool, config: TypoConfig<'a>) -> QueryKind {
if authorize_typos && !config.exact_words.as_ref().map(|s| s.contains(&word)).unwrap_or(false) {
if authorize_typos && !config.exact_words.map_or(false, |s| s.contains(&word)) {
let count = word.chars().count().min(u8::MAX as usize) as u8;
if count < config.word_len_one_typo {
QueryKind::exact(word)