Include image alt text in post search (#5449)

* Add Alt-Text Filter to post_view.rs

Added Alt-text filter to search

* Actually use the Alt-text filter I added

Add the call to actually use the alt-text filter I added.

* Create down.sql of migration

* Create up.sql

* Fixing SQL format.

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>
This commit is contained in:
Draconic NEO 2025-02-26 03:28:15 +09:00 committed by GitHub
parent 493734d1b3
commit 1a299ba628
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View file

@ -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)));
}

View file

@ -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);

View file

@ -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);