mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
feat(search): expand default search scope and support specific field filtering
This commit is contained in:
@@ -1168,6 +1168,18 @@ impl DuckDBManager {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(subject) = filter.subject {
|
||||
let pattern = format!("(?i){}", subject);
|
||||
base_sql.push_str(" AND regexp_matches(coalesce(e.subject, ''), ?)");
|
||||
args.push(pattern.into());
|
||||
}
|
||||
|
||||
if let Some(body) = filter.body {
|
||||
let pattern = format!("(?i){}", body);
|
||||
base_sql.push_str(" AND regexp_matches(coalesce(e.body, ''), ?)");
|
||||
args.push(pattern.into());
|
||||
}
|
||||
|
||||
if let Some(text) = filter.text {
|
||||
let pattern = format!("(?i){}", text);
|
||||
base_sql.push_str(
|
||||
@@ -1175,10 +1187,14 @@ impl DuckDBManager {
|
||||
AND (
|
||||
regexp_matches(coalesce(e.subject, ''), ?)
|
||||
OR regexp_matches(coalesce(e.body, ''), ?)
|
||||
OR regexp_matches(coalesce(e.sender, ''), ?)
|
||||
OR regexp_matches(array_to_string(e.recipients, ','), ?)
|
||||
)
|
||||
",
|
||||
);
|
||||
args.push(pattern.clone().into());
|
||||
args.push(pattern.clone().into());
|
||||
args.push(pattern.clone().into());
|
||||
args.push(pattern.into());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user