Compare commits
2 Commits
a6165a0f2e
...
532d1560a3
| Author | SHA1 | Date | |
|---|---|---|---|
| 532d1560a3 | |||
| 894fa3fc1d |
@@ -582,7 +582,7 @@ func (db *DB) SearchThoughtsText(ctx context.Context, query string, limit int, p
|
|||||||
args := []any{query}
|
args := []any{query}
|
||||||
conditions := []string{
|
conditions := []string{
|
||||||
"t.archived_at is null",
|
"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 {
|
if projectID != nil {
|
||||||
args = append(args, *projectID)
|
args = append(args, *projectID)
|
||||||
@@ -596,9 +596,10 @@ func (db *DB) SearchThoughtsText(ctx context.Context, query string, limit int, p
|
|||||||
|
|
||||||
q := `
|
q := `
|
||||||
select t.guid, t.content, t.metadata,
|
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
|
t.created_at
|
||||||
from thoughts t
|
from thoughts t
|
||||||
|
left join projects p on t.project_id = p.guid
|
||||||
where ` + strings.Join(conditions, " and ") + `
|
where ` + strings.Join(conditions, " and ") + `
|
||||||
order by similarity desc
|
order by similarity desc
|
||||||
limit $` + fmt.Sprintf("%d", len(args))
|
limit $` + fmt.Sprintf("%d", len(args))
|
||||||
|
|||||||
Reference in New Issue
Block a user