add authorize typo setting

This commit is contained in:
ad hoc
2022-03-16 10:03:18 +01:00
parent d8dd357326
commit c4653347fd
4 changed files with 50 additions and 3 deletions

View File

@ -112,7 +112,11 @@ impl<'a> Search<'a> {
Some(query) => {
let mut builder = QueryTreeBuilder::new(self.rtxn, self.index);
builder.optional_words(self.optional_words);
builder.authorize_typos(self.authorize_typos);
// only authorize typos if both the index and the query allow it.
let index_authorizes_typos = self.index.authorize_typos(self.rtxn)?;
builder.authorize_typos(self.authorize_typos && index_authorizes_typos);
builder.words_limit(self.words_limit);
// We make sure that the analyzer is aware of the stop words
// this ensures that the query builder is able to properly remove them.

View File

@ -191,7 +191,6 @@ impl<'a> QueryTreeBuilder<'a> {
/// generated forcing all query words to be present in each matching documents
/// (the criterion `words` will be ignored).
/// default value if not called: `true`
#[allow(unused)]
pub fn optional_words(&mut self, optional_words: bool) -> &mut Self {
self.optional_words = optional_words;
self
@ -201,7 +200,6 @@ impl<'a> QueryTreeBuilder<'a> {
/// forcing all query words to match documents without any typo
/// (the criterion `typo` will be ignored).
/// default value if not called: `true`
#[allow(unused)]
pub fn authorize_typos(&mut self, authorize_typos: bool) -> &mut Self {
self.authorize_typos = authorize_typos;
self