Fossil

Check-in [7b6adfbf92]
Login

Check-in [7b6adfbf92]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Take out the "test-fts" command and replace it with "fts-config" which has a more user-friendly format. Add "fts-config" to the "all" command too.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7b6adfbf92ca9fefee20221417e1504c8452b61d
User & Date: drh 2015-02-03 16:40:16.126
Context
2015-02-03
16:54
Get "fossil rebuild" to work on an indexed database, and automatically recompute the index. ... (check-in: 18c0ab6bf1 user: drh tags: trunk)
16:40
Take out the "test-fts" command and replace it with "fts-config" which has a more user-friendly format. Add "fts-config" to the "all" command too. ... (check-in: 7b6adfbf92 user: drh tags: trunk)
15:24
Use a CROSS JOIN to fix an inefficient query in the indexed full-text search. ... (check-in: 005ba1e28f user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/allrepo.c.
232
233
234
235
236
237
238



239
240
241
242
243
244
245
    collect_argument(&extra, "wal",0);
    collect_argument(&extra, "stats",0);
  }else if( strncmp(zCmd, "setting", n)==0 ){
    zCmd = "setting -R";
    collect_argv(&extra, 3);
  }else if( strncmp(zCmd, "unset", n)==0 ){
    zCmd = "unset -R";



    collect_argv(&extra, 3);
  }else if( strncmp(zCmd, "sync", n)==0 ){
    zCmd = "sync -autourl -R";
    collect_argument(&extra, "verbose","v");
  }else if( strncmp(zCmd, "test-integrity", n)==0 ){
    collect_argument(&extra, "parse", 0);
    zCmd = "test-integrity";







>
>
>







232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
    collect_argument(&extra, "wal",0);
    collect_argument(&extra, "stats",0);
  }else if( strncmp(zCmd, "setting", n)==0 ){
    zCmd = "setting -R";
    collect_argv(&extra, 3);
  }else if( strncmp(zCmd, "unset", n)==0 ){
    zCmd = "unset -R";
    collect_argv(&extra, 3);
  }else if( strncmp(zCmd, "fts-config", n)==0 ){
    zCmd = "fts-config -R";
    collect_argv(&extra, 3);
  }else if( strncmp(zCmd, "sync", n)==0 ){
    zCmd = "sync -autourl -R";
    collect_argument(&extra, "verbose","v");
  }else if( strncmp(zCmd, "test-integrity", n)==0 ){
    collect_argument(&extra, "parse", 0);
    zCmd = "test-integrity";
Changes to src/search.c.
1361
1362
1363
1364
1365
1366
1367
1368


















1369
1370
1371
1372
1373
1374
1375
1376
1377


1378
1379

1380
1381




1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393

1394









1395
1396
1397
1398
1399

1400





1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414


1415
1416
1417
1418
1419

1420
1421

1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435


1436
1437
1438

1439
1440





1441
1442
1443
  }
  if( srchFlags & SRCH_WIKI ){
    search_update_wiki_index();
  }
}

/*
** COMMAND: test-fts


















*/
void test_fts_cmd(void){
  char *zSubCmd;
  int i, n;
  static const struct { int iCmd; const char *z; } aCmd[] = {
     { 1,  "create"    },
     { 2,  "drop"      },
     { 3,  "exists"    },
     { 4,  "fill"      },


     { 8,  "refill"    },
     { 5,  "pending"   },

     { 7,  "update"    },
  };




  db_find_and_open_repository(0, 0);
  if( g.argc<3 ) usage("SUBCMD ...");
  zSubCmd = g.argv[2];
  n = (int)strlen(zSubCmd);
  for(i=0; i<ArraySize(aCmd); i++){
    if( fossil_strncmp(aCmd[i].z, zSubCmd, n)==0 ) break;
  }
  if( i>=ArraySize(aCmd) ){
    Blob all;
    blob_init(&all,0,0);
    for(i=0; i<ArraySize(aCmd); i++) blob_appendf(&all, " %s", aCmd[i].z);
    fossil_fatal("unknown \"%s\" - should be:%s", zSubCmd, blob_str(&all));

    return;









  }
  db_begin_transaction();
  switch( aCmd[i].iCmd ){
    case 1: {  assert( fossil_strncmp(zSubCmd, "create", n)==0 );
      search_create_index();

      break;





    }
    case 2: {  assert( fossil_strncmp(zSubCmd, "drop", n)==0 );
      search_drop_index();
      break;
    }
    case 3: {  assert( fossil_strncmp(zSubCmd, "exists", n)==0 );
      fossil_print("search_index_exists() = %d\n", search_index_exists());
      break;
    }
    case 4: {  assert( fossil_strncmp(zSubCmd, "fill", n)==0 );
      search_fill_index();
      break;
    }
    case 8: {  assert( fossil_strncmp(zSubCmd, "refill", n)==0 );


      search_drop_index();
      search_create_index();
      search_fill_index();
      break;
    }

    case 5: {  assert( fossil_strncmp(zSubCmd, "pending", n)==0 );
      Stmt q;

      if( !search_index_exists() ) break;
      db_prepare(&q, "SELECT rowid,type,rid,quote(name) FROM ftsdocs"
                     " WHERE NOT idxed");
      while( db_step(&q)==SQLITE_ROW ){
        fossil_print("%6d: %s %6d %s\n",
           db_column_int(&q, 0),
           db_column_text(&q, 1),
           db_column_int(&q, 2),
           db_column_text(&q, 3)
        );
      }
      db_finalize(&q);
      break;
    }


    case 7: {  assert( fossil_strncmp(zSubCmd, "update", n)==0 );
      search_update_index(SRCH_ALL);
      break;

    }






  }
  db_end_transaction(0);
}







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


<
<

|
|
|
|
>
>
|
|
>
|

>
>
>
>

|
|
|
|
|
|
|
|
|
|
|
>
|
>
>
>
>
>
>
>
>
>


|
<
|
>
|
>
>
>
>
>
|
<
<
<

<
<
<
|
<
<
<
|
<
>
>
|
<
<
<
|
>
|
<
>
|
<
|
|
|
<
<
<
<
<
|
<
<
|
>
>
|
<
<
>
|
|
>
>
>
>
>



1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388


1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430

1431
1432
1433
1434
1435
1436
1437
1438
1439



1440



1441



1442

1443
1444
1445



1446
1447
1448

1449
1450

1451
1452
1453





1454


1455
1456
1457
1458


1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
  }
  if( srchFlags & SRCH_WIKI ){
    search_update_wiki_index();
  }
}

/*
** COMMAND: fts-config*
**
** Usage: fossil fts-config ?SUBCOMMAND? ?ARGUMENT?
**
** The "fossil fts-config" command configures the full-text search capabilities
** of the repository.  Subcommands:
**
**     reindex            Rebuild the search index.  Create it if it does
**                        not already exist
**
**     index (on|off)     Turn the search index on or off
**
**     enable cdtw        Enable various kinds of search. c=Check-ins,
**                        d=Documents, t=Tickets, w=Wiki.
**
**     disable cdtw       Disable versious kinds of search
**
** The current search settings are displayed after any changes are applied.
** Run this command with no arguments to simply see the settings.
*/
void test_fts_cmd(void){


  static const struct { int iCmd; const char *z; } aCmd[] = {
     { 1,  "reindex"  },
     { 2,  "index"    },
     { 3,  "disable"  },
     { 4,  "enable"   },
  };
  static const struct { char *zSetting; char *zName; char *zSw; } aSetng[] = {
     { "search-ckin",  "check-in search:",  "c" },
     { "search-doc",   "document search:",  "d" },
     { "search-tkt",   "ticket search:",    "t" },
     { "search-wiki",  "wiki search:",      "w" },
  };
  char *zSubCmd;
  int i, j, n;
  int iCmd = 0;
  int iAction = 0;
  db_find_and_open_repository(0, 0);
  if( g.argc>2 ){
    zSubCmd = g.argv[2];
    n = (int)strlen(zSubCmd);
    for(i=0; i<ArraySize(aCmd); i++){
      if( fossil_strncmp(aCmd[i].z, zSubCmd, n)==0 ) break;
    }
    if( i>=ArraySize(aCmd) ){
      Blob all;
      blob_init(&all,0,0);
      for(i=0; i<ArraySize(aCmd); i++) blob_appendf(&all, " %s", aCmd[i].z);
      fossil_fatal("unknown \"%s\" - should be on of:%s",
                   zSubCmd, blob_str(&all));
      return;
    }
    iCmd = aCmd[i].iCmd;
  }
  if( iCmd==1 ){
    iAction = 2;
  }
  if( iCmd==2 ){
    if( g.argc<3 ) usage("index (on|off)");
    iAction = 1 + is_truth(g.argv[3]);
  }
  db_begin_transaction();


  /* Adjust search settings */
  if( iCmd==3 || iCmd==4 ){
    const char *zCtrl;
    if( g.argc<4 ) usage("enable STRING");
    zCtrl = g.argv[3];
    for(j=0; j<ArraySize(aSetng); j++){
      if( strchr(zCtrl, aSetng[j].zSw[0])!=0 ){
        db_set_int(aSetng[j].zSetting, iCmd-3, 0);
      }



    }



  }





  /* destroy or rebuild the index, if requested */
  if( iAction>=1 ){
    search_drop_index();



  }
  if( iAction>=2 ){
    fossil_print("rebuilding the search index...");

    fflush(stdout);
    search_create_index();

    search_fill_index();
    search_update_index(search_restrict(SRCH_ALL));
    fossil_print(" done\n");





  }



  /* Always show the status before ending */
  for(i=0; i<ArraySize(aSetng); i++){
    fossil_print("%-16s %s\n", aSetng[i].zName, 


       db_get_boolean(aSetng[i].zSetting,0) ? "on" : "off");
  }
  if( search_index_exists() ){
    fossil_print("%-16s enabled\n", "full-text index:");
    fossil_print("%-16s %d\n", "documents:",
       db_int(0, "SELECT count(*) FROM ftsdocs"));
  }else{
    fossil_print("%-16s disabled\n", "full-text index:");
  }
  db_end_transaction(0);
}