Fossil

Changes On Branch patmaddox/search-branches
Login

Changes On Branch patmaddox/search-branches

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

Changes In Branch patmaddox/search-branches Excluding Merge-Ins

This is equivalent to a diff from 94c8af02ea to 3de86b7676

2024-08-31
17:30
Revert the temporary fix [9866c97b35] as the underlying problem has been resolved in SQLite. ... (check-in: ecaeb31f51 user: florian tags: trunk)
2024-08-30
09:39
Proposed fix for the search branch bug reported in [forum:520d420d04e482b2|forum post 520d420d04]. This seems to work but could use more testing. To hit the affected query, first run (fossil fts-config index off) then (fossil search -fts ...terms...). ... (Closed-Leaf check-in: f4fdd7d385 user: stephan tags: search-branch-fix)
05:19
document multiple branch search ... (Leaf check-in: 3de86b7676 user: patmaddox tags: patmaddox/search-branches)
05:17
index search multiple branches ... (check-in: 6a4415e769 user: patmaddox tags: patmaddox/search-branches)
04:26
plain-text search the configured doc branch Previously, it would always search trunk, but build links using the doc branch ... (check-in: 29f1fbf3ae user: patmaddox tags: patmaddox/search-branches)
2024-08-27
19:38
Fix one mis-changed line in [898a70ce82a5] which would have broken builds on OS/2. ... (check-in: 94c8af02ea user: stephan tags: trunk)
11:19
When stdout is not a tty, avoid doing the carriage-return-to-reuse-the-console-line trick for emiting metrics while syncing, and instead emit the stats after the end of the loop. This means that log files from cron jobs no longer contain the carriage-return clutter. ... (check-in: f8800f3464 user: stephan tags: trunk)

Changes to src/search.c.

790
791
792
793
794
795
796

797
798
799
800
801

802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818

819
820
821
822
823
824
825
  const char *zPattern,       /* The query pattern */
  unsigned int srchFlags      /* What to search over */
){
  search_init(zPattern, "<mark>", "</mark>", " ... ",
          SRCHFLG_STATIC|SRCHFLG_HTML);
  if( (srchFlags & SRCH_DOC)!=0 ){
    char *zDocGlob = db_get("doc-glob","");

    char *zDocBr = db_get("doc-branch","trunk");
    if( zDocGlob && zDocGlob[0] && zDocBr && zDocBr[0] ){
      db_multi_exec(
        "CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;"
      );

      db_multi_exec(
        "INSERT INTO x(label,url,score,id,date,snip)"
        "  SELECT printf('Document: %%s',title('d',blob.rid,foci.filename)),"
        "         printf('/doc/%T/%%s',foci.filename),"
        "         search_score(),"
        "         'd'||blob.rid,"
        "         (SELECT datetime(event.mtime) FROM event"
        "            WHERE objid=symbolic_name_to_rid('trunk')),"
        "         search_snippet()"
        "    FROM foci CROSS JOIN blob"
        "   WHERE checkinID=symbolic_name_to_rid('trunk')"
        "     AND blob.uuid=foci.uuid"
        "     AND search_match(title('d',blob.rid,foci.filename),"
        "                      body('d',blob.rid,foci.filename))"
        "     AND %z",
        zDocBr, glob_expr("foci.filename", zDocGlob)
      );

    }
  }
  if( (srchFlags & SRCH_WIKI)!=0 ){
    db_multi_exec(
      "WITH wiki(name,rid,mtime) AS ("
      "  SELECT substr(tagname,6), tagxref.rid, max(tagxref.mtime)"
      "    FROM tag, tagxref"







>
|
|



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







790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
  const char *zPattern,       /* The query pattern */
  unsigned int srchFlags      /* What to search over */
){
  search_init(zPattern, "<mark>", "</mark>", " ... ",
          SRCHFLG_STATIC|SRCHFLG_HTML);
  if( (srchFlags & SRCH_DOC)!=0 ){
    char *zDocGlob = db_get("doc-glob","");
    char *zDocBranches = db_get("doc-branch","trunk");
    char *zDocBr = NULL;
    if( zDocGlob && zDocGlob[0] && zDocBranches && zDocBranches[0] ){
      db_multi_exec(
        "CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;"
      );
      while ((zDocBr = strsep(&zDocBranches, ",")) != NULL) {
        db_multi_exec(
          "INSERT INTO x(label,url,score,id,date,snip)"
          "  SELECT printf('Document: %%s',title('d',blob.rid,foci.filename)),"
          "         printf('/doc/%T/%%s',foci.filename),"
          "         search_score(),"
          "         'd'||blob.rid,"
          "         (SELECT datetime(event.mtime) FROM event"
          "            WHERE objid=symbolic_name_to_rid('%T')),"
          "         search_snippet()"
          "    FROM foci CROSS JOIN blob"
          "   WHERE checkinID=symbolic_name_to_rid('%T')"
          "     AND blob.uuid=foci.uuid"
          "     AND search_match(title('d',blob.rid,foci.filename),"
          "                      body('d',blob.rid,foci.filename))"
          "     AND %z",
          zDocBr, zDocBr, zDocBr, glob_expr("foci.filename", zDocGlob)
        );
      }
    }
  }
  if( (srchFlags & SRCH_WIKI)!=0 ){
    db_multi_exec(
      "WITH wiki(name,rid,mtime) AS ("
      "  SELECT substr(tagname,6), tagxref.rid, max(tagxref.mtime)"
      "    FROM tag, tagxref"
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895











1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931

1932
1933
1934
1935
1936
1937
1938
/*
** If the doc-glob and doc-br settings are valid for document search
** and if the latest check-in on doc-br is in the unindexed set of
** check-ins, then update all 'd' entries in FTSDOCS that have
** changed.
*/
static void search_update_doc_index(void){
  const char *zDocBr = db_get("doc-branch","trunk");
  int ckid = zDocBr ? symbolic_name_to_rid(zDocBr,"ci") : 0;
  double rTime;
  if( ckid==0 ) return;
  if( !db_exists("SELECT 1 FROM ftsdocs WHERE type='c' AND rid=%d"
                 "   AND NOT idxed", ckid) ) return;

  /* If we get this far, it means that changes to 'd' entries are
  ** required. */
  rTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", ckid);
  db_multi_exec(
    "CREATE TEMP TABLE current_docs(rid INTEGER PRIMARY KEY, name);"
    "CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;"











    "INSERT OR IGNORE INTO current_docs(rid, name)"
    "  SELECT blob.rid, foci.filename FROM foci, blob"
    "   WHERE foci.checkinID=%d AND blob.uuid=foci.uuid"
    "     AND %z",
    ckid, glob_expr("foci.filename", db_get("doc-glob",""))
  );
  db_multi_exec(
    "DELETE FROM ftsidx WHERE rowid IN"
    "  (SELECT rowid FROM ftsdocs WHERE type='d'"
    "      AND rid NOT IN (SELECT rid FROM current_docs))"
  );
  db_multi_exec(
    "DELETE FROM ftsdocs WHERE type='d'"
    "      AND rid NOT IN (SELECT rid FROM current_docs)"
  );
  db_multi_exec(
    "INSERT OR IGNORE INTO ftsdocs(type,rid,name,idxed,label,bx,url,mtime)"
    "  SELECT 'd', rid, name, 0,"
    "         title('d',rid,name),"
    "         body('d',rid,name),"
    "         printf('/doc/%T/%%s',urlencode(name)),"
    "         %.17g"
    " FROM current_docs",
    zDocBr, rTime
  );
  db_multi_exec(
    "INSERT INTO ftsidx(rowid,title,body)"
    "  SELECT rowid, label, bx FROM ftsdocs WHERE type='d' AND NOT idxed"
  );
  db_multi_exec(
    "UPDATE ftsdocs SET"
    "  idxed=1,"
    "  bx=NULL,"
    "  label='Document: '||label"
    " WHERE type='d' AND NOT idxed"
  );

}

/*
** Deal with all of the unindexed 'c' terms in FTSDOCS
*/
static void search_update_checkin_index(void){
  db_multi_exec(







|
<
<
<
<
<
|
<
<
<



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







1879
1880
1881
1882
1883
1884
1885
1886





1887



1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
/*
** If the doc-glob and doc-br settings are valid for document search
** and if the latest check-in on doc-br is in the unindexed set of
** check-ins, then update all 'd' entries in FTSDOCS that have
** changed.
*/
static void search_update_doc_index(void){
  char *zDocBranches = db_get("doc-branch","trunk");





  char *zDocBr = NULL;



  db_multi_exec(
    "CREATE TEMP TABLE current_docs(rid INTEGER PRIMARY KEY, name);"
    "CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;"
  );
  while ((zDocBr = strsep(&zDocBranches, ",")) != NULL) {
    int ckid = symbolic_name_to_rid(zDocBr,"ci");
    double rTime;
    if( !db_exists("SELECT 1 FROM ftsdocs WHERE type='c' AND rid=%d"
                   "   AND NOT idxed", ckid) ) continue;
  
    /* If we get this far, it means that changes to 'd' entries are
    ** required. */
    rTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", ckid);
    db_multi_exec(
      "INSERT OR IGNORE INTO current_docs(rid, name)"
      "  SELECT blob.rid, foci.filename FROM foci, blob"
      "   WHERE foci.checkinID=%d AND blob.uuid=foci.uuid"
      "     AND %z",
      ckid, glob_expr("foci.filename", db_get("doc-glob",""))
    );
    db_multi_exec(
      "DELETE FROM ftsidx WHERE rowid IN"
      "  (SELECT rowid FROM ftsdocs WHERE type='d'"
      "      AND rid NOT IN (SELECT rid FROM current_docs))"
    );
    db_multi_exec(
      "DELETE FROM ftsdocs WHERE type='d'"
      "      AND rid NOT IN (SELECT rid FROM current_docs)"
    );
    db_multi_exec(
      "INSERT OR IGNORE INTO ftsdocs(type,rid,name,idxed,label,bx,url,mtime)"
      "  SELECT 'd', rid, name, 0,"
      "         title('d',rid,name),"
      "         body('d',rid,name),"
      "         printf('/doc/%T/%%s',urlencode(name)),"
      "         %.17g"
      " FROM current_docs",
      zDocBr, rTime
    );
    db_multi_exec(
      "INSERT INTO ftsidx(rowid,title,body)"
      "  SELECT rowid, label, bx FROM ftsdocs WHERE type='d' AND NOT idxed"
    );
    db_multi_exec(
      "UPDATE ftsdocs SET"
      "  idxed=1,"
      "  bx=NULL,"
      "  label='Document: '||label"
      " WHERE type='d' AND NOT idxed"
    );
  }
}

/*
** Deal with all of the unindexed 'c' terms in FTSDOCS
*/
static void search_update_checkin_index(void){
  db_multi_exec(

Changes to src/setup.c.

2189
2190
2191
2192
2193
2194
2195

2196
2197
2198
2199
2200
2201
2202
  @ <td>Search nothing. (Disables document search).</tr>
  @ </table>
  @ <hr>
  entry_attribute("Document Branch", 20, "doc-branch", "db", "trunk", 0);
  @ <p>When searching documents, use the versions of the files found at the
  @ type of the "Document Branch" branch.  Recommended value: "trunk".
  @ Document search is disabled if blank.

  @ <hr>
  onoff_attribute("Search Check-in Comments", "search-ci", "sc", 0, 0);
  @ <br>
  onoff_attribute("Search Documents", "search-doc", "sd", 0, 0);
  @ <br>
  onoff_attribute("Search Tickets", "search-tkt", "st", 0, 0);
  @ <br>







>







2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
  @ <td>Search nothing. (Disables document search).</tr>
  @ </table>
  @ <hr>
  entry_attribute("Document Branch", 20, "doc-branch", "db", "trunk", 0);
  @ <p>When searching documents, use the versions of the files found at the
  @ type of the "Document Branch" branch.  Recommended value: "trunk".
  @ Document search is disabled if blank.
  @ Comma-separate multiple branches: "trunk,docs".
  @ <hr>
  onoff_attribute("Search Check-in Comments", "search-ci", "sc", 0, 0);
  @ <br>
  onoff_attribute("Search Documents", "search-doc", "sd", 0, 0);
  @ <br>
  onoff_attribute("Search Tickets", "search-tkt", "st", 0, 0);
  @ <br>