Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include image alt text in post search #5449

Merged
merged 5 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/db_views/src/post/post_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

Original file line number Diff line number Diff line change
@@ -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);