Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix the bm25() function so that it multiplies scores by -1 before returning them. This means better matches have a lower numerical score, so "ORDER BY rank" (not "ORDER BY rank DESC") does what you want. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | fts5 |
Files: | files | file ages | folders |
SHA1: |
3ee7b5a9f987c269251620ae7cc0fc78 |
User & Date: | dan 2015-03-07 11:50:31.532 |
Context
2015-03-07
| ||
15:46 | Fix some compiler warnings caused by signed/unsigned pointer conversions. (check-in: cccee7b5b1 user: dan tags: fts5) | |
11:50 | Fix the bm25() function so that it multiplies scores by -1 before returning them. This means better matches have a lower numerical score, so "ORDER BY rank" (not "ORDER BY rank DESC") does what you want. (check-in: 3ee7b5a9f9 user: dan tags: fts5) | |
2015-03-04
| ||
08:29 | Fix a couple of build problems. (check-in: a5d5468c05 user: dan tags: fts5) | |
Changes
Changes to ext/fts5/fts5.h.
︙ | ︙ | |||
96 97 98 99 100 101 102 | ** xTokenize: ** Tokenize text using the tokenizer belonging to the FTS5 table. ** ** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback): ** This API function is used to query the FTS table for phrase iPhrase ** of the current query. Specifically, a query equivalent to: ** | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | ** xTokenize: ** Tokenize text using the tokenizer belonging to the FTS5 table. ** ** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback): ** This API function is used to query the FTS table for phrase iPhrase ** of the current query. Specifically, a query equivalent to: ** ** ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid ** ** with $p set to a phrase equivalent to the phrase iPhrase of the ** current query is executed. For each row visited, the callback function ** passed as the fourth argument is invoked. The context and API objects ** passed to the callback function may be used to access the properties of ** each matched row. Invoking Api.xUserData() returns a copy of the pointer ** passed as the third argument to pUserData. |
︙ | ︙ |
Changes to ext/fts5/fts5_aux.c.
︙ | ︙ | |||
516 517 518 519 520 521 522 | ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) ) ); } /* If no error has occurred, return the calculated score. Otherwise, ** throw an SQL exception. */ if( rc==SQLITE_OK ){ | | | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) ) ); } /* If no error has occurred, return the calculated score. Otherwise, ** throw an SQL exception. */ if( rc==SQLITE_OK ){ sqlite3_result_double(pCtx, -1.0 * score); }else{ sqlite3_result_error_code(pCtx, rc); } } int sqlite3Fts5AuxInit(fts5_api *pApi){ struct Builtin { |
︙ | ︙ |
Changes to ext/fts5/fts5_hash.c.
︙ | ︙ | |||
65 66 67 68 69 70 71 | int iCol; /* Column of last value written */ int iPos; /* Position of last value written */ i64 iRowid; /* Rowid of last value written */ char zKey[0]; /* Nul-terminated entry key */ }; | < < < < < < < < < < < < < < < < < < < < < < | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | int iCol; /* Column of last value written */ int iPos; /* Position of last value written */ i64 iRowid; /* Rowid of last value written */ char zKey[0]; /* Nul-terminated entry key */ }; /* ** Allocate a new hash table. */ int sqlite3Fts5HashNew(Fts5Hash **ppNew, int *pnByte){ int rc = SQLITE_OK; Fts5Hash *pNew; |
︙ | ︙ |
Changes to ext/fts5/test/fts5ae.test.
︙ | ︙ | |||
261 262 263 264 265 266 267 | 2 {b} {3 1} 3 {c} {1 0} 4 {d} {2 3} 5 {g AND (e OR f)} {5 4} 6 {j AND (h OR i)} {5 6} } { do_execsql_test 8.2.$tn.1 { | | | | | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | 2 {b} {3 1} 3 {c} {1 0} 4 {d} {2 3} 5 {g AND (e OR f)} {5 4} 6 {j AND (h OR i)} {5 6} } { do_execsql_test 8.2.$tn.1 { SELECT rowid FROM t8 WHERE t8 MATCH $q ORDER BY bm25(t8); } $res do_execsql_test 8.2.$tn.2 { SELECT rowid FROM t8 WHERE t8 MATCH $q ORDER BY +rank; } $res do_execsql_test 8.2.$tn.3 { SELECT rowid FROM t8 WHERE t8 MATCH $q ORDER BY rank; } $res } finish_test |