]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the bm25() function so that it multiplies scores by -1 before returning them...
authordan <dan@noemail.net>
Sat, 7 Mar 2015 11:50:31 +0000 (11:50 +0000)
committerdan <dan@noemail.net>
Sat, 7 Mar 2015 11:50:31 +0000 (11:50 +0000)
FossilOrigin-Name: 3ee7b5a9f987c269251620ae7cc0fc7876b58ee5

ext/fts5/fts5.h
ext/fts5/fts5_aux.c
ext/fts5/fts5_hash.c
ext/fts5/test/fts5ae.test
manifest
manifest.uuid

index 8e244f39927cb713c787420d36fc3a3834bc065f..28be0de676b0e1c8c86693cc9c1a3d81836fe9c2 100644 (file)
@@ -100,7 +100,7 @@ typedef void (*fts5_extension_function)(
 **   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 DESC
+**       ... 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
index fbd786640e961248255838360f727d6ba493b398..8e4beffe676dd163ea26d237b25584b16fa030d5 100644 (file)
@@ -520,7 +520,7 @@ static void fts5Bm25Function(
   /* If no error has occurred, return the calculated score. Otherwise,
   ** throw an SQL exception.  */
   if( rc==SQLITE_OK ){
-    sqlite3_result_double(pCtx, score);
+    sqlite3_result_double(pCtx, -1.0 * score);
   }else{
     sqlite3_result_error_code(pCtx, rc);
   }
index bd17205f1cda4a62b8192a6668bdd3f4e15ebc23..69425a33103df176d107eeedba8ce6f113c6aa47 100644 (file)
@@ -69,28 +69,6 @@ struct Fts5HashEntry {
   char zKey[0];                   /* Nul-terminated entry key */
 };
 
-/*
-** Format value iVal as a 4-byte varint and write it to buffer a[]. 4 bytes
-** are used even if the value could fit in a smaller amount of space. 
-*/
-static void fts5Put4ByteVarint(u8 *a, int iVal){
-  a[0] = (0x80 | (u8)(iVal >> 21));
-  a[1] = (0x80 | (u8)(iVal >> 14));
-  a[2] = (0x80 | (u8)(iVal >>  7));
-  a[3] = (0x7F & (u8)(iVal));
-}
-
-static int fts5Get4ByteVarint(u8 *a, int *pnVarint){
-  int iRet = ((int)(a[0] & 0x7F) << 21) + ((int)(a[1] & 0x7F) << 14)
-       + ((int)(a[2] & 0x7F) <<  7) + ((int)(a[3]));
-  *pnVarint = (
-      (iRet & 0xFFFFFF80)==0 ? 1 : 
-      (iRet & 0xFFFFC000)==0 ? 2 :
-      (iRet & 0xFFE00000)==0 ? 3 : 4
-  );
-  return iRet;
-}
-
 /*
 ** Allocate a new hash table.
 */
index c9c3fcce30effa3ff47c04a29cf98bb9cbce5467..d310e723be5dad334f96394e3e8a599dc687495f 100644 (file)
@@ -265,15 +265,15 @@ foreach {tn q res} {
   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) DESC;
+    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 DESC;
+    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 DESC;
+    SELECT rowid FROM t8 WHERE t8 MATCH $q ORDER BY rank;
   } $res
 }
 
index 1f0b00ef27bfd17b31e87ca4c35777fdc3884935..7124437f180089c56d4c60b0ede23d174b4a5ec4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\scouple\sof\sbuild\sproblems.
-D 2015-03-04T08:29:24.833
+C Fix\sthe\sbm25()\sfunction\sso\sthat\sit\smultiplies\sscores\sby\s-1\sbefore\sreturning\sthem.\sThis\smeans\sbetter\smatches\shave\sa\slower\snumerical\sscore,\sso\s"ORDER\sBY\srank"\s(not\s"ORDER\sBY\srank\sDESC")\sdoes\swhat\syou\swant.
+D 2015-03-07T11:50:31.532
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -105,13 +105,13 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7
 F ext/fts3/unicode/mkunicode.tcl 159c1194da0bc72f51b3c2eb71022568006dc5ad
 F ext/fts5/extract_api_docs.tcl 55a6d648d516f35d9a1e580ac00de27154e1904a
 F ext/fts5/fts5.c 1eb8ca073be5222c43e4eee5408764c2cbb4200b
-F ext/fts5/fts5.h f931954065693898d26c51f23f1d27200184a69a
+F ext/fts5/fts5.h 24a2cc35b5e76eec57b37ba48c12d9d2cb522b3a
 F ext/fts5/fts5Int.h 5c8efea3d0a1ccc70194225f8c402a1732ed5ad5
-F ext/fts5/fts5_aux.c c64e56b08c5be52fa688c078259cf903b164937a
+F ext/fts5/fts5_aux.c fcea18b1a2a3f95a498b52aba2983557d7678a22
 F ext/fts5/fts5_buffer.c 29f79841bf6eef5220eef41b122419b1bcb07b06
 F ext/fts5/fts5_config.c 0847facc8914f57ea4452c43ce109200dc65e894
 F ext/fts5/fts5_expr.c 5215137efab527577d36bdf9e44bfc2ec3e1be98
-F ext/fts5/fts5_hash.c 6bc0f78cb3630c5ff27dbfb58847758e82c3d0ac
+F ext/fts5/fts5_hash.c 13fcefb50a178c0f5086b88cdd781e26c413a3cb
 F ext/fts5/fts5_index.c db8dc4cf906245dfd8a8d724695b60d6f22b7654
 F ext/fts5/fts5_storage.c ac0f0937059c8d4f38a1f13aa5f2c2cd7edf3e0d
 F ext/fts5/fts5_tcl.c 617b6bb96545be8d9045de6967c688cd9cd15541
@@ -124,7 +124,7 @@ F ext/fts5/test/fts5aa.test 065767c60ad301f77ad95f24369305e13347aa00
 F ext/fts5/test/fts5ab.test 5da2e92a8047860b9e22b6fd3990549639d631b1
 F ext/fts5/test/fts5ac.test 8b3c2938840da8f3f6a53b1324fb03e0bac12d1e
 F ext/fts5/test/fts5ad.test 2141b0360dc4397bfed30f0b0d700fa64b44835d
-F ext/fts5/test/fts5ae.test 347c96db06aab23ff00cf6a6b4064a8dbb182e42
+F ext/fts5/test/fts5ae.test 9175201baf8c885fc1cbb2da11a0c61fd11224db
 F ext/fts5/test/fts5af.test c2501ec2b61d6b179c305f5d2b8782ab3d4f832a
 F ext/fts5/test/fts5ag.test ec3e119b728196620a31507ef503c455a7a73505
 F ext/fts5/test/fts5ah.test 56b5a2599707621bf2fd1b5a00ddc0c0c1ffbf06
@@ -1284,7 +1284,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P a07dcca9ef3821a6719ef9dbbc8ed861fa005035
-R c94fdf40731aa277dc09f612ab9d1498
+P a5d5468c0509d129e198bf9432190ee07cedb7af
+R aa671856811e9ea4e67d518a4616a999
 U dan
-Z 4c98d611f9675f463f695743f454384f
+Z 4764624a6d652eca0ea7813e6c8b51f7
index fe120d997a1e34bf8b4ac4383f8eb3a44456d54c..11c1b204aeeed1328b7d9dc28919e9d900f83fea 100644 (file)
@@ -1 +1 @@
-a5d5468c0509d129e198bf9432190ee07cedb7af
\ No newline at end of file
+3ee7b5a9f987c269251620ae7cc0fc7876b58ee5
\ No newline at end of file