From 894fa3fc1d95661c645cefac0f30b446cad25122 Mon Sep 17 00:00:00 2001 From: sgcommand Date: Tue, 21 Apr 2026 08:31:42 +0200 Subject: [PATCH] fix: include project names in thought text search --- internal/store/thoughts.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/store/thoughts.go b/internal/store/thoughts.go index 1819a2e..56188b4 100644 --- a/internal/store/thoughts.go +++ b/internal/store/thoughts.go @@ -582,7 +582,7 @@ func (db *DB) SearchThoughtsText(ctx context.Context, query string, limit int, p args := []any{query} conditions := []string{ "t.archived_at is null", - "to_tsvector('simple', t.content) @@ websearch_to_tsquery('simple', $1)", + "(to_tsvector('simple', t.content) || to_tsvector('simple', coalesce(p.name, ''))) @@ websearch_to_tsquery('simple', $1)", } if projectID != nil { args = append(args, *projectID) @@ -596,9 +596,10 @@ func (db *DB) SearchThoughtsText(ctx context.Context, query string, limit int, p q := ` select t.guid, t.content, t.metadata, - ts_rank_cd(to_tsvector('simple', t.content), websearch_to_tsquery('simple', $1)) as similarity, + ts_rank_cd(to_tsvector('simple', t.content) || to_tsvector('simple', coalesce(p.name, '')), websearch_to_tsquery('simple', $1)) as similarity, t.created_at from thoughts t + left join projects p on t.project_id = p.guid where ` + strings.Join(conditions, " and ") + ` order by similarity desc limit $` + fmt.Sprintf("%d", len(args)) -- 2.49.1