mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +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
|
@ -1369,12 +1369,18 @@ pub fn perform_facet_search(
|
|||
None => TimeBudget::default(),
|
||||
};
|
||||
|
||||
// In the faceted search context, we want to use the intersection between the locales provided by the user
|
||||
// and the locales of the facet string.
|
||||
// If the facet string is not localized, we **ignore** the locales provided by the user because the facet data has no locale.
|
||||
// If the user does not provide locales, we use the locales of the facet string.
|
||||
let localized_attributes = index.localized_attributes_rules(&rtxn)?.unwrap_or_default();
|
||||
let locales = locales.or_else(|| {
|
||||
localized_attributes
|
||||
let localized_attributes_locales =
|
||||
localized_attributes.into_iter().find(|attr| attr.match_str(&facet_name));
|
||||
let locales = localized_attributes_locales.map(|attr| {
|
||||
attr.locales
|
||||
.into_iter()
|
||||
.find(|attr| attr.match_str(&facet_name))
|
||||
.map(|attr| attr.locales)
|
||||
.filter(|locale| locales.as_ref().map_or(true, |locales| locales.contains(locale)))
|
||||
.collect()
|
||||
});
|
||||
|
||||
let (search, _, _, _) =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue