Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Apply the logic in/around [ec68aaf42536b4fb] to the chat search so that it does not abort, and generate an error log entry, when given characters which fts5 does not like. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | fts5-chat-search |
| Files: | files | file ages | folders |
| SHA3-256: |
b698ba99427d3a530e2d5ea7a64afd84 |
| User & Date: | stephan 2024-07-03 10:26:35.923 |
Context
|
2024-07-03
| ||
| 12:38 | Add /chat history search. ... (check-in: fc853823b2 user: stephan tags: trunk) | |
| 10:26 | Apply the logic in/around [ec68aaf42536b4fb] to the chat search so that it does not abort, and generate an error log entry, when given characters which fts5 does not like. ... (Closed-Leaf check-in: b698ba9942 user: stephan tags: fts5-chat-search) | |
|
2024-07-02
| ||
| 12:04 | Chat help text cleanups and add a FIXME regarding connection failure (as opposed to HTTP-level errors) while polling for new chat messages (which is not a new problem, but is one which came up while working on fts5-chat-search). ... (check-in: 4711a8c4dd user: stephan tags: fts5-chat-search) | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
blob_append_sql(&sql,
"SELECT msgid, datetime(mtime), xfrom, "
" xmsg, octet_length(file), fname, fmime, mdel, lmtime "
" FROM chat WHERE msgid=+%Q",
zQuery
);
}else{
blob_append_sql(&sql,
"SELECT * FROM ("
"SELECT c.msgid, datetime(c.mtime), c.xfrom, "
" highlight(chatfts1, 0, '<span class=\"match\">', '</span>'), "
" octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime "
" FROM chatfts1(%Q) f, chat c "
" WHERE f.rowid=c.msgid"
" ORDER BY f.rowid DESC LIMIT %d"
| > | > | 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 |
blob_append_sql(&sql,
"SELECT msgid, datetime(mtime), xfrom, "
" xmsg, octet_length(file), fname, fmime, mdel, lmtime "
" FROM chat WHERE msgid=+%Q",
zQuery
);
}else{
char * zPat = search_simplify_pattern(zQuery);
blob_append_sql(&sql,
"SELECT * FROM ("
"SELECT c.msgid, datetime(c.mtime), c.xfrom, "
" highlight(chatfts1, 0, '<span class=\"match\">', '</span>'), "
" octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime "
" FROM chatfts1(%Q) f, chat c "
" WHERE f.rowid=c.msgid"
" ORDER BY f.rowid DESC LIMIT %d"
") ORDER BY 1 ASC", zPat, nLimit
);
fossil_free(zPat);
}
}else{
blob_append_sql(&sql,
"SELECT msgid, datetime(mtime), xfrom, "
" xmsg, octet_length(file), fname, fmime, mdel, lmtime"
" FROM chat WHERE msgid>=%d LIMIT %d",
iFirst, nLimit
|
| ︙ | ︙ |
Changes to src/search.c.
| ︙ | ︙ | |||
973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
blob_appendf(&x," r=%g", r);
sqlite3_result_text(context, blob_str(&x), -1, fossil_free);
}
#else
sqlite3_result_double(context, r);
#endif
}
/*
** When this routine is called, there already exists a table
**
** x(label,url,score,id,snip).
**
** label: The "name" of the document containing the match
| > > > > > > > > > > > > > > > > > > > > > > > | 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 |
blob_appendf(&x," r=%g", r);
sqlite3_result_text(context, blob_str(&x), -1, fossil_free);
}
#else
sqlite3_result_double(context, r);
#endif
}
/*
** Expects a search pattern string. Makes a copy of the string,
** replaces all non-alphanum ASCII characters with a space, and
** lower-cases all upper-case ASCII characters. The intent is to avoid
** causing errors in FTS5 searches with inputs which contain AND, OR,
** and symbols like #. The caller is responsible for passing the
** result to fossil_free().
*/
char *search_simplify_pattern(const char * zPattern){
char *zPat = mprintf("%s",zPattern);
int i;
for(i=0; zPat[i]; i++){
if( (zPat[i]&0x80)==0 && !fossil_isalnum(zPat[i]) ) zPat[i] = ' ';
if( fossil_isupper(zPat[i]) ) zPat[i] = fossil_tolower(zPat[i]);
}
for(i--; i>=0 && zPat[i]==' '; i--){}
if( i<0 ){
fossil_free(zPat);
zPat = mprintf("\"\"");
}
return zPat;
}
/*
** When this routine is called, there already exists a table
**
** x(label,url,score,id,snip).
**
** label: The "name" of the document containing the match
|
| ︙ | ︙ | |||
995 996 997 998 999 1000 1001 |
** The companion full-scan search routine is search_fullscan().
*/
LOCAL void search_indexed(
const char *zPattern, /* The query pattern */
unsigned int srchFlags /* What to search over */
){
Blob sql;
| | < < < < < < < < | < | 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 |
** The companion full-scan search routine is search_fullscan().
*/
LOCAL void search_indexed(
const char *zPattern, /* The query pattern */
unsigned int srchFlags /* What to search over */
){
Blob sql;
char *zPat;
static const char *zSnippetCall;
if( srchFlags==0 ) return;
sqlite3_create_function(g.db, "rank", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
search_rank_sqlfunc, 0, 0);
zPat = search_simplify_pattern(zPattern);
blob_init(&sql, 0, 0);
if( search_index_type(0)==4 ){
/* If this repo is still using the legacy FTS4 search index, then
** the snippet() function is slightly different */
zSnippetCall = "snippet(ftsidx,'<mark>','</mark>',' ... ',-1,35)";
}else{
/* This is the common case - Using newer FTS5 search index */
|
| ︙ | ︙ |