~sircmpwn/godocs.io

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH gddo] internal/database: Improve search SQL query

Details
Message ID
<20210430195526.22844-1-me@adnano.co>
DKIM signature
pass
Download raw message
Patch: +2 -1
Rank the results by relevance first, and then by score.
---
 internal/database/database.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/internal/database/database.go b/internal/database/database.go
index 5de50bd..5fd8d18 100644
--- a/internal/database/database.go
+++ b/internal/database/database.go
@@ -132,7 +132,8 @@ func (db *Database) Search(ctx context.Context, q string) ([]Package, error) {
			WHERE p.searchtext @@ websearch_to_tsquery('english', $1)
				AND m.module_path = p.module_path AND p.version = m.latest_version
				AND i.import_path = p.import_path
			ORDER BY score DESC, import_path ASC
			ORDER BY ts_rank(p.searchtext, to_tsquery('english', $1)) DESC,
				p.score ASC
			LIMIT 20;
			`, q)
		if err != nil {
-- 
2.31.1
Details
Message ID
<CB22MM52S8X2.2JSKYZQEO6428@taiga>
In-Reply-To
<20210430195526.22844-1-me@adnano.co> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Thanks!

To git@git.sr.ht:~sircmpwn/gddo
   dfc2f02..24ba5a5  master -> master
Reply to thread Export thread (mbox)