diff --git a/meilisearch/src/routes/indexes/facet_search.rs b/meilisearch/src/routes/indexes/facet_search.rs index 4d6950988..3f05fa846 100644 --- a/meilisearch/src/routes/indexes/facet_search.rs +++ b/meilisearch/src/routes/indexes/facet_search.rs @@ -69,7 +69,7 @@ pub async fn search( // Tenant token search_rules. if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) { - add_search_rules(&mut search_query, search_rules); + add_search_rules(&mut search_query.filter, search_rules); } let index = index_scheduler.index(&index_uid)?; diff --git a/meilisearch/src/routes/indexes/search.rs b/meilisearch/src/routes/indexes/search.rs index 5581e6a68..8628da6d9 100644 --- a/meilisearch/src/routes/indexes/search.rs +++ b/meilisearch/src/routes/indexes/search.rs @@ -196,7 +196,7 @@ pub async fn search_with_url_query( // Tenant token search_rules. if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) { - add_search_rules(&mut query, search_rules); + add_search_rules(&mut query.filter, search_rules); } let mut aggregate = SearchAggregator::from_query(&query, &req); @@ -235,7 +235,7 @@ pub async fn search_with_post( // Tenant token search_rules. if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) { - add_search_rules(&mut query, search_rules); + add_search_rules(&mut query.filter, search_rules); } let mut aggregate = SearchAggregator::from_query(&query, &req); diff --git a/meilisearch/src/routes/multi_search.rs b/meilisearch/src/routes/multi_search.rs index 7b7cbd265..a83dc4bc0 100644 --- a/meilisearch/src/routes/multi_search.rs +++ b/meilisearch/src/routes/multi_search.rs @@ -67,7 +67,7 @@ pub async fn multi_search_with_post( // Apply search rules from tenant token if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) { - add_search_rules(&mut query, search_rules); + add_search_rules(&mut query.filter, search_rules); } let index = index_scheduler diff --git a/meilisearch/src/search.rs b/meilisearch/src/search.rs index 94690d121..7c3813b55 100644 --- a/meilisearch/src/search.rs +++ b/meilisearch/src/search.rs @@ -570,8 +570,8 @@ pub struct FacetSearchResult { } /// Incorporate search rules in search query -pub fn add_search_rules(query: &mut SearchQuery, rules: IndexSearchRules) { - query.filter = match (query.filter.take(), rules.filter) { +pub fn add_search_rules(filter: &mut Option, rules: IndexSearchRules) { + *filter = match (filter.take(), rules.filter) { (None, rules_filter) => rules_filter, (filter, None) => filter, (Some(filter), Some(rules_filter)) => {