diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-26 22:11:52 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-26 22:11:52 +0200 |
| commit | c2b3f184df4a60a872eea77971cd83ea6d8297b0 (patch) | |
| tree | 9d0b4533679fc45d992ae1354c652221bffd8667 /app | |
| parent | 289ec85be338c6c9085497820f53f57ee714b9b7 (diff) | |
Enable full-text search via PostgreSQL tsvector on page_translations
- Restore search vector migration (was parked in doc/ pending PostgreSQL upgrade)
- Restore Node.search using plainto_tsquery with simple dictionary
- Cross-locale keyword search, no stemming, works for both de and en content
Diffstat (limited to 'app')
| -rw-r--r-- | app/models/node.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 41c3867..a3ef23a 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -211,11 +211,13 @@ class Node < ApplicationRecord | |||
| 211 | self.created_at < new_id_format_date ? unique_path : id | 211 | self.created_at < new_id_format_date ? unique_path : id |
| 212 | end | 212 | end |
| 213 | 213 | ||
| 214 | # TODO: restore full-text search once PostgreSQL is upgraded. | 214 | # Full-text search across all locale translations using PostgreSQL tsvector. |
| 215 | # The tsvector/plpgsql approach requires PostgreSQL 10+ with plpgsql available. | 215 | # Uses 'simple' dictionary (no stemming, no stopwords) so queries work |
| 216 | # For now, search is disabled to unblock the Rails 7.2 upgrade. | 216 | # across German and English content without language detection. |
| 217 | def self.search(term, _ = {}) | 217 | def self.search(term, _ = {}) |
| 218 | none | 218 | joins(head: :translations) |
| 219 | .where("page_translations.search_vector @@ plainto_tsquery('simple', ?)", term) | ||
| 220 | .distinct | ||
| 219 | end | 221 | end |
| 220 | 222 | ||
| 221 | protected | 223 | protected |
