add search rules directly takes the filter rather than the searchquery

This commit is contained in:
Louis Dureuil 2024-05-27 10:53:16 +02:00
parent 02b3d82c60
commit e172e938e7
No known key found for this signature in database
4 changed files with 6 additions and 6 deletions

View File

@ -69,7 +69,7 @@ pub async fn search(
// Tenant token search_rules. // Tenant token search_rules.
if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) { 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)?; let index = index_scheduler.index(&index_uid)?;

View File

@ -196,7 +196,7 @@ pub async fn search_with_url_query(
// Tenant token search_rules. // Tenant token search_rules.
if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) { 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); let mut aggregate = SearchAggregator::from_query(&query, &req);
@ -235,7 +235,7 @@ pub async fn search_with_post(
// Tenant token search_rules. // Tenant token search_rules.
if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) { 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); let mut aggregate = SearchAggregator::from_query(&query, &req);

View File

@ -67,7 +67,7 @@ pub async fn multi_search_with_post(
// Apply search rules from tenant token // Apply search rules from tenant token
if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid) 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 let index = index_scheduler

View File

@ -570,8 +570,8 @@ pub struct FacetSearchResult {
} }
/// Incorporate search rules in search query /// Incorporate search rules in search query
pub fn add_search_rules(query: &mut SearchQuery, rules: IndexSearchRules) { pub fn add_search_rules(filter: &mut Option<Value>, rules: IndexSearchRules) {
query.filter = match (query.filter.take(), rules.filter) { *filter = match (filter.take(), rules.filter) {
(None, rules_filter) => rules_filter, (None, rules_filter) => rules_filter,
(filter, None) => filter, (filter, None) => filter,
(Some(filter), Some(rules_filter)) => { (Some(filter), Some(rules_filter)) => {