| | @@ -1136,28 +1136,32 @@ |
| 1136 | 1136 | ; |
| 1137 | 1137 | |
| 1138 | 1138 | /* |
| 1139 | 1139 | ** Create or drop the tables associated with a full-text index. |
| 1140 | 1140 | */ |
| 1141 | +static int searchIdxExists = -1; |
| 1141 | 1142 | void search_create_index(void){ |
| 1142 | 1143 | const char *zDb = db_name("repository"); |
| 1143 | 1144 | search_sql_setup(g.db); |
| 1144 | 1145 | db_multi_exec(zFtsSchema/*works-like:"%w%w%w%w%w"*/, |
| 1145 | 1146 | zDb, zDb, zDb, zDb, zDb); |
| 1147 | + searchIdxExists = 1; |
| 1146 | 1148 | } |
| 1147 | 1149 | void search_drop_index(void){ |
| 1148 | 1150 | const char *zDb = db_name("repository"); |
| 1149 | 1151 | db_multi_exec(zFtsDrop/*works-like:"%w%w%w"*/, zDb, zDb, zDb); |
| 1152 | + searchIdxExists = 0; |
| 1150 | 1153 | } |
| 1151 | 1154 | |
| 1152 | 1155 | /* |
| 1153 | 1156 | ** Return true if the full-text search index exists |
| 1154 | 1157 | */ |
| 1155 | 1158 | int search_index_exists(void){ |
| 1156 | | - static int fExists = -1; |
| 1157 | | - if( fExists<0 ) fExists = db_table_exists("repository","ftsdocs"); |
| 1158 | | - return fExists; |
| 1159 | + if( searchIdxExists<0 ){ |
| 1160 | + searchIdxExists = db_table_exists("repository","ftsdocs"); |
| 1161 | + } |
| 1162 | + return searchIdxExists; |
| 1159 | 1163 | } |
| 1160 | 1164 | |
| 1161 | 1165 | /* |
| 1162 | 1166 | ** Fill the FTSDOCS table with unindexed entries for everything |
| 1163 | 1167 | ** in the repository. This uses INSERT OR IGNORE so entries already |
| | @@ -1361,10 +1365,22 @@ |
| 1361 | 1365 | } |
| 1362 | 1366 | if( srchFlags & SRCH_WIKI ){ |
| 1363 | 1367 | search_update_wiki_index(); |
| 1364 | 1368 | } |
| 1365 | 1369 | } |
| 1370 | + |
| 1371 | +/* |
| 1372 | +** Construct, prepopulate, and then update the full-text index. |
| 1373 | +*/ |
| 1374 | +void search_rebuild_index(void){ |
| 1375 | + fossil_print("rebuilding the search index..."); |
| 1376 | + fflush(stdout); |
| 1377 | + search_create_index(); |
| 1378 | + search_fill_index(); |
| 1379 | + search_update_index(search_restrict(SRCH_ALL)); |
| 1380 | + fossil_print(" done\n"); |
| 1381 | +} |
| 1366 | 1382 | |
| 1367 | 1383 | /* |
| 1368 | 1384 | ** COMMAND: fts-config* |
| 1369 | 1385 | ** |
| 1370 | 1386 | ** Usage: fossil fts-config ?SUBCOMMAND? ?ARGUMENT? |
| | @@ -1443,16 +1459,11 @@ |
| 1443 | 1459 | /* destroy or rebuild the index, if requested */ |
| 1444 | 1460 | if( iAction>=1 ){ |
| 1445 | 1461 | search_drop_index(); |
| 1446 | 1462 | } |
| 1447 | 1463 | if( iAction>=2 ){ |
| 1448 | | - fossil_print("rebuilding the search index..."); |
| 1449 | | - fflush(stdout); |
| 1450 | | - search_create_index(); |
| 1451 | | - search_fill_index(); |
| 1452 | | - search_update_index(search_restrict(SRCH_ALL)); |
| 1453 | | - fossil_print(" done\n"); |
| 1464 | + search_rebuild_index(); |
| 1454 | 1465 | } |
| 1455 | 1466 | |
| 1456 | 1467 | /* Always show the status before ending */ |
| 1457 | 1468 | for(i=0; i<ArraySize(aSetng); i++){ |
| 1458 | 1469 | fossil_print("%-16s %s\n", aSetng[i].zName, |
| 1459 | 1470 | |