mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
table.search_sql(include_rank=True) option (#480)
* search_sql add include_rank option * add test * add FTS4 test * Apply Black Thanks, @chapmanjacobd
This commit is contained in:
parent
087753cd42
commit
ecf1d40112
2 changed files with 48 additions and 0 deletions
|
|
@ -556,6 +556,50 @@ def test_enable_fts_error_message_on_views():
|
|||
" rank_bm25(matchinfo([books_fts], 'pcnalx'))"
|
||||
),
|
||||
),
|
||||
(
|
||||
{"include_rank": True},
|
||||
"FTS5",
|
||||
(
|
||||
"with original as (\n"
|
||||
" select\n"
|
||||
" rowid,\n"
|
||||
" *\n"
|
||||
" from [books]\n"
|
||||
")\n"
|
||||
"select\n"
|
||||
" [original].*,\n"
|
||||
" [books_fts].rank rank\n"
|
||||
"from\n"
|
||||
" [original]\n"
|
||||
" join [books_fts] on [original].rowid = [books_fts].rowid\n"
|
||||
"where\n"
|
||||
" [books_fts] match :query\n"
|
||||
"order by\n"
|
||||
" [books_fts].rank"
|
||||
),
|
||||
),
|
||||
(
|
||||
{"include_rank": True},
|
||||
"FTS4",
|
||||
(
|
||||
"with original as (\n"
|
||||
" select\n"
|
||||
" rowid,\n"
|
||||
" *\n"
|
||||
" from [books]\n"
|
||||
")\n"
|
||||
"select\n"
|
||||
" [original].*,\n"
|
||||
" rank_bm25(matchinfo([books_fts], 'pcnalx')) rank\n"
|
||||
"from\n"
|
||||
" [original]\n"
|
||||
" join [books_fts] on [original].rowid = [books_fts].rowid\n"
|
||||
"where\n"
|
||||
" [books_fts] match :query\n"
|
||||
"order by\n"
|
||||
" rank_bm25(matchinfo([books_fts], 'pcnalx'))"
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_search_sql(kwargs, fts, expected):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue