aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-10-19 21:40:59 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-10-19 21:40:59 -0700
commita614f980634003dae14b3675125f704d37856d0b (patch)
tree752cd758dccf660313b5e4e2369247b2e5091d9c /storage
parent715575001a2b5a96fa0cfc4402d29c959f1f48a0 (diff)
Set arbitrary maximum size for tsvector column
- The max size for tsvector is 1 MiB - We index only the first million of characters, it should be enough for most feed entries.
Diffstat (limited to 'storage')
-rw-r--r--storage/entry.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/storage/entry.go b/storage/entry.go
index ff081d4..5aa8b45 100644
--- a/storage/entry.go
+++ b/storage/entry.go
@@ -50,7 +50,7 @@ func (s *Storage) UpdateEntryContent(entry *model.Entry) error {
query := `
UPDATE entries
- SET document_vectors = to_tsvector(title || ' ' || coalesce(content, ''))
+ SET document_vectors = to_tsvector(substring(title || ' ' || coalesce(content, '') for 1000000))
WHERE id=$1 AND user_id=$2
`
_, err = tx.Exec(query, entry.ID, entry.UserID)
@@ -68,7 +68,7 @@ func (s *Storage) createEntry(entry *model.Entry) error {
INSERT INTO entries
(title, hash, url, comments_url, published_at, content, author, user_id, feed_id, document_vectors)
VALUES
- ($1, $2, $3, $4, $5, $6, $7, $8, $9, to_tsvector($1 || ' ' || coalesce($6, '')))
+ ($1, $2, $3, $4, $5, $6, $7, $8, $9, to_tsvector(substring($1 || ' ' || coalesce($6, '') for 1000000)))
RETURNING id, status
`
err := s.db.QueryRow(
@@ -107,7 +107,7 @@ func (s *Storage) updateEntry(entry *model.Entry) error {
query := `
UPDATE entries SET
title=$1, url=$2, comments_url=$3, content=$4, author=$5,
- document_vectors=to_tsvector($1 || ' ' || coalesce($4, ''))
+ document_vectors=to_tsvector(substring($1 || ' ' || coalesce($4, '') for 1000000))
WHERE user_id=$6 AND feed_id=$7 AND hash=$8
RETURNING id
`