From 863dd03c673f38287663c56912d28666c6d7401b Mon Sep 17 00:00:00 2001 From: Jacob Chapman <7908073+chapmanjacobd@users.noreply.github.com> Date: Tue, 30 Aug 2022 04:08:55 -0500 Subject: [PATCH] search_sql add include_rank option --- sqlite_utils/db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index b653cc4..4c6c0e2 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -2376,6 +2376,7 @@ class Table(Queryable): limit: Optional[int] = None, offset: Optional[int] = None, where: Optional[str] = None, + include_rank: bool = False, ) -> str: """ " Return SQL string that can be used to execute searches against this table. @@ -2427,6 +2428,8 @@ class Table(Queryable): rank_implementation = "rank_bm25(matchinfo([{}], 'pcnalx'))".format( fts_table ) + if include_rank: + columns_with_prefix_sql += ",\n " + rank_implementation + " rank" limit_offset = "" if limit is not None: limit_offset += " limit {}".format(limit)