diff --git a/modules/files/lib.py b/modules/files/lib.py index 4a215094..56ff95ae 100644 --- a/modules/files/lib.py +++ b/modules/files/lib.py @@ -157,6 +157,7 @@ def search(search_str: str, limit: int, offset: int): SELECT id, ts_rank_cd(textsearch, websearch_to_tsquery(%(search_str)s)), COUNT(*) OVER() AS total FROM file WHERE textsearch @@ websearch_to_tsquery(%(search_str)s) + ORDER BY 2, 1 OFFSET %(offset)s LIMIT %(limit)s ''' params = dict(search_str=search_str, offset=offset, limit=limit) diff --git a/modules/files/models.py b/modules/files/models.py index 09ee70c8..8578925a 100644 --- a/modules/files/models.py +++ b/modules/files/models.py @@ -18,7 +18,7 @@ class File(ModelHelper, Base): title = deferred(Column(String)) # used by textsearch column textsearch = deferred( - Column(tsvector, Computed('''to_tsvector('english'::regconfig, title)'''))) + Column(tsvector, Computed('''setweight(to_tsvector('english'::regconfig, title), 'A'::"char")'''))) def __repr__(self): return f''