Merge pull request #5541 from meilisearch/deactivate-numbers-in-typos-enhancements

Minor fixes: Deactivate numbers in typos
This commit is contained in:
Many the fish 2025-05-26 14:36:21 +00:00 committed by GitHub
commit a1ff41cabb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 20 deletions

View File

@ -2045,7 +2045,7 @@ async fn test_exact_typos_terms() {
}),
&json!({"q": "12345"}),
|response, code| {
assert_eq!(code, 200, "{}", response);
assert_eq!(code, 200, "{response}");
snapshot!(json_string!(response["hits"]), @r###"
[
{
@ -2080,7 +2080,7 @@ async fn test_exact_typos_terms() {
}),
&json!({"q": "123457"}),
|response, code| {
assert_eq!(code, 200, "{}", response);
assert_eq!(code, 200, "{response}");
snapshot!(json_string!(response["hits"]), @r###"[]"###);
},
)

View File

@ -33,13 +33,6 @@ impl Index {
Ok(())
}
pub(crate) fn delete_disabled_typos_terms(&self, txn: &mut RwTxn<'_>) -> heed::Result<()> {
self.main
.remap_types::<Str, SerdeJson<DisabledTyposTerms>>()
.delete(txn, main_key::DISABLED_TYPOS_TERMS)?;
Ok(())
}
}
impl DisabledTyposTerms {

View File

@ -131,7 +131,12 @@ fn compute_word_fst(
}
}
pub fn recompute_word_fst_from_word_docids_database(index: &Index, wtxn: &mut RwTxn) -> Result<()> {
pub fn recompute_word_fst_from_word_docids_database(
index: &Index,
wtxn: &mut RwTxn,
progress: &Progress,
) -> Result<()> {
progress.update_progress(PostProcessingWords::WordFst);
let fst = fst::Set::default().map_data(std::borrow::Cow::Owned)?;
let mut word_fst_builder = WordFstBuilder::new(&fst)?;
let words = index.word_docids.iter(wtxn)?.remap_data_type::<DecodeIgnore>();

View File

@ -884,7 +884,6 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> {
disabled_typos_terms.disable_on_numbers = disable_on_numbers;
}
Setting::Reset => {
self.index.delete_disabled_typos_terms(self.wtxn)?;
disabled_typos_terms.disable_on_numbers =
DisabledTyposTerms::default().disable_on_numbers;
}

View File

@ -3,7 +3,7 @@ use heed::RwTxn;
use super::UpgradeIndex;
use crate::progress::Progress;
use crate::update::new::indexer::recompute_word_fst_from_word_docids_database;
use crate::{make_enum_progress, Index, Result};
use crate::{Index, Result};
#[allow(non_camel_case_types)]
pub(super) struct Latest_V1_14_To_Latest_V1_15();
@ -17,14 +17,7 @@ impl UpgradeIndex for Latest_V1_14_To_Latest_V1_15 {
progress: Progress,
) -> Result<bool> {
// Recompute the word FST from the word docids database.
make_enum_progress! {
enum TypoTolerance {
RecomputeWordFst,
}
};
progress.update_progress(TypoTolerance::RecomputeWordFst);
recompute_word_fst_from_word_docids_database(index, wtxn)?;
recompute_word_fst_from_word_docids_database(index, wtxn, &progress)?;
Ok(false)
}