mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
Only detect language for a facet if several locales have been specified by the user in the settings
This commit is contained in:
parent
0e68718027
commit
ade54493ab
3 changed files with 26 additions and 7 deletions
|
@ -339,10 +339,18 @@ impl ValuesCollection {
|
|||
fn normalize_facet_string(facet_string: &str, locales: Option<&[Language]>) -> String {
|
||||
let options = NormalizerOption { lossy: true, ..Default::default() };
|
||||
let mut detection = StrDetection::new(facet_string, locales);
|
||||
|
||||
// Detect the language of the facet string only if several locales are explicitly provided.
|
||||
let language = match locales {
|
||||
Some(&[language]) => Some(language),
|
||||
Some(multiple_locales) if multiple_locales.len() > 1 => detection.language(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let token = Token {
|
||||
lemma: std::borrow::Cow::Borrowed(facet_string),
|
||||
script: detection.script(),
|
||||
language: detection.language(),
|
||||
language,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ fn extract_facet_string_docids_settings<R: io::Read + io::Seek>(
|
|||
/// Normalizes the facet string and truncates it to the max length.
|
||||
#[tracing::instrument(level = "trace", skip_all, target = "indexing::extract")]
|
||||
fn normalize_facet_string(facet_string: &str, locales: Option<&[Language]>) -> String {
|
||||
let options = NormalizerOption { lossy: true, ..Default::default() };
|
||||
let options: NormalizerOption = NormalizerOption { lossy: true, ..Default::default() };
|
||||
let mut detection = StrDetection::new(facet_string, locales);
|
||||
|
||||
let script = {
|
||||
|
@ -285,7 +285,12 @@ fn normalize_facet_string(facet_string: &str, locales: Option<&[Language]>) -> S
|
|||
let span = tracing::trace_span!(target: "indexing::extract::extract_facet_string_docids", "detect_language");
|
||||
let _entered = span.enter();
|
||||
|
||||
detection.language()
|
||||
// Detect the language of the facet string only if several locales are explicitly provided.
|
||||
match locales {
|
||||
Some(&[language]) => Some(language),
|
||||
Some(multiple_locales) if multiple_locales.len() > 1 => detection.language(),
|
||||
_ => None,
|
||||
}
|
||||
};
|
||||
|
||||
let token = Token {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue