diff --git a/crates/db_views/src/post/post_view.rs b/crates/db_views/src/post/post_view.rs index 68c838f8af..8539896213 100644 --- a/crates/db_views/src/post/post_view.rs +++ b/crates/db_views/src/post/post_view.rs @@ -489,10 +489,11 @@ impl<'a> PostQuery<'a> { let searcher = fuzzy_search(search_term); let name_filter = post::name.ilike(searcher.clone()); let body_filter = post::body.ilike(searcher.clone()); + let alt_text_filter = post::alt_text.ilike(searcher.clone()); query = if o.title_only.unwrap_or_default() { query.filter(name_filter) } else { - query.filter(name_filter.or(body_filter)) + query.filter(name_filter.or(body_filter).or(alt_text_filter)) } .filter(not(post::removed.or(post::deleted))); } diff --git a/migrations/2025-02-24-173152_search-alt-text-of-posts/down.sql b/migrations/2025-02-24-173152_search-alt-text-of-posts/down.sql new file mode 100644 index 0000000000..5d1b726118 --- /dev/null +++ b/migrations/2025-02-24-173152_search-alt-text-of-posts/down.sql @@ -0,0 +1,4 @@ +DROP INDEX idx_post_trigram; + +CREATE INDEX IF NOT EXISTS idx_post_trigram ON post USING gin (name gin_trgm_ops, body gin_trgm_ops); + diff --git a/migrations/2025-02-24-173152_search-alt-text-of-posts/up.sql b/migrations/2025-02-24-173152_search-alt-text-of-posts/up.sql new file mode 100644 index 0000000000..21eb206337 --- /dev/null +++ b/migrations/2025-02-24-173152_search-alt-text-of-posts/up.sql @@ -0,0 +1,4 @@ +DROP INDEX idx_post_trigram; + +CREATE INDEX IF NOT EXISTS idx_post_trigram ON post USING gin (name gin_trgm_ops, body gin_trgm_ops, alt_text gin_trgm_ops); +