mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
Merge pull request #5494 from meilisearch/deactivate-numbers-in-typos
Deactivate numbers in typos
This commit is contained in:
commit
96bc519f9e
19 changed files with 296 additions and 35 deletions
|
@ -8,6 +8,7 @@ use std::str::FromStr;
|
|||
|
||||
use deserr::{DeserializeError, Deserr, ErrorKind, MergeWithError, ValuePointerRef};
|
||||
use fst::IntoStreamer;
|
||||
use milli::disabled_typos_terms::DisabledTyposTerms;
|
||||
use milli::index::{IndexEmbeddingConfig, PrefixSearch};
|
||||
use milli::proximity::ProximityPrecision;
|
||||
use milli::update::Setting;
|
||||
|
@ -104,6 +105,10 @@ pub struct TypoSettings {
|
|||
#[deserr(default)]
|
||||
#[schema(value_type = Option<BTreeSet<String>>, example = json!(["uuid", "url"]))]
|
||||
pub disable_on_attributes: Setting<BTreeSet<String>>,
|
||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||
#[deserr(default)]
|
||||
#[schema(value_type = Option<bool>, example = json!(true))]
|
||||
pub disable_on_numbers: Setting<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, Deserr, ToSchema)]
|
||||
|
@ -701,6 +706,12 @@ pub fn apply_settings_to_builder(
|
|||
Setting::Reset => builder.reset_exact_attributes(),
|
||||
Setting::NotSet => (),
|
||||
}
|
||||
|
||||
match value.disable_on_numbers {
|
||||
Setting::Set(val) => builder.set_disable_on_numbers(val),
|
||||
Setting::Reset => builder.reset_disable_on_numbers(),
|
||||
Setting::NotSet => (),
|
||||
}
|
||||
}
|
||||
Setting::Reset => {
|
||||
// all typo settings need to be reset here.
|
||||
|
@ -826,12 +837,14 @@ pub fn settings(
|
|||
};
|
||||
|
||||
let disabled_attributes = index.exact_attributes(rtxn)?.into_iter().map(String::from).collect();
|
||||
let DisabledTyposTerms { disable_on_numbers } = index.disabled_typos_terms(rtxn)?;
|
||||
|
||||
let typo_tolerance = TypoSettings {
|
||||
enabled: Setting::Set(index.authorize_typos(rtxn)?),
|
||||
min_word_size_for_typos: Setting::Set(min_typo_word_len),
|
||||
disable_on_words: Setting::Set(disabled_words),
|
||||
disable_on_attributes: Setting::Set(disabled_attributes),
|
||||
disable_on_numbers: Setting::Set(disable_on_numbers),
|
||||
};
|
||||
|
||||
let faceting = FacetingSettings {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue