Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add support for the "columnname : phrase" syntax to fts5. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
069e299d061d27423ccbfa515cba2ecd |
User & Date: | dan 2012-12-30 12:03:06.072 |
Context
2013-01-01
| ||
09:07 | Avoid leaking shared-memory pages when rolling back a large transaction. check-in: d9a06d9403 user: dan tags: trunk | |
2012-12-30
| ||
12:03 | Add support for the "columnname : phrase" syntax to fts5. check-in: 069e299d06 user: dan tags: trunk | |
11:45 | Add support for prefix queries to fts5. Still no support for prefix indexes, just prefix queries using the regular term index. check-in: dd018f834a user: dan tags: trunk | |
Changes
Changes to src/fts5.c.
︙ | ︙ | |||
1925 1926 1927 1928 1929 1930 1931 | return 0; } } return (p->iCol==pFirst->iCol && p->iOff==iReq); } | | | 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 | return 0; } } return (p->iCol==pFirst->iCol && p->iOff==iReq); } static int fts5StringFindInstances(Fts5Cursor *pCsr, int iCol, Fts5Str *pStr){ int i; int rc = SQLITE4_OK; int bEof = 0; int nByte = sizeof(InstanceList) * pStr->nToken; InstanceList *aIn; InstanceList out; |
︙ | ︙ | |||
1966 1967 1968 1969 1970 1971 1972 | } while( rc==SQLITE4_OK && bEof==0 ){ for(i=1; i<pStr->nToken; i++){ int bMatch = fts5TokenAdvanceToMatch(&aIn[i], &aIn[0], i, &bEof); if( bMatch==0 || bEof ) break; } | | | 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 | } while( rc==SQLITE4_OK && bEof==0 ){ for(i=1; i<pStr->nToken; i++){ int bMatch = fts5TokenAdvanceToMatch(&aIn[i], &aIn[0], i, &bEof); if( bMatch==0 || bEof ) break; } if( i==pStr->nToken && (iCol<0 || aIn[0].iCol==iCol) ){ /* Record a match here */ fts5InstanceListAppend(&out, aIn[0].iCol, aIn[0].iWeight, aIn[0].iOff); } bEof = fts5InstanceListNext(&aIn[0]); } pStr->nList = out.iList; |
︙ | ︙ | |||
2086 2087 2088 2089 2090 2091 2092 | /* At this point, it is established that all of the token cursors in the ** phrase point to an entry with the same primary key. Now figure out if ** the various string constraints are met. Along the way, synthesize a ** position list for each Fts5Str object. */ for(i=0; rc==SQLITE4_OK && i<pPhrase->nStr; i++){ Fts5Str *pStr = &pPhrase->aStr[i]; | | | 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 | /* At this point, it is established that all of the token cursors in the ** phrase point to an entry with the same primary key. Now figure out if ** the various string constraints are met. Along the way, synthesize a ** position list for each Fts5Str object. */ for(i=0; rc==SQLITE4_OK && i<pPhrase->nStr; i++){ Fts5Str *pStr = &pPhrase->aStr[i]; rc = fts5StringFindInstances(pCsr, pPhrase->iCol, pStr); } /* Trim the instance lists according to any NEAR constraints. */ for(i=1; rc==SQLITE4_OK && i<pPhrase->nStr; i++){ int n = pPhrase->aiNear[i-1]; rc = fts5StringNearTrim(pCsr, &pPhrase->aStr[i], &pPhrase->aStr[i-1], n); } |
︙ | ︙ |
Changes to test/fts5query1.test.
︙ | ︙ | |||
99 100 101 102 103 104 105 | INSERT INTO t3 VALUES(123, 'fix the hash table', NULL, NULL); } do_execsql_test 5.1 { SELECT docid FROM t3 WHERE t3 MATCH 'h*'; } {123} do_execsql_test 6.0 { | < | | | | < | | < < > > > > > > > > > > > > > > > > > > > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | INSERT INTO t3 VALUES(123, 'fix the hash table', NULL, NULL); } do_execsql_test 5.1 { SELECT docid FROM t3 WHERE t3 MATCH 'h*'; } {123} do_execsql_test 6.0 { BEGIN TRANSACTION; CREATE TABLE t4(docid PRIMARY KEY, a); CREATE INDEX i4 ON t4 USING fts5(); INSERT INTO "t4" VALUES(34, 'abc mnm xyz'); INSERT INTO "t4" VALUES(50, 'abc mnm xyz'); COMMIT; } do_execsql_test 6.1 { SELECT docid FROM t4 WHERE t4 MATCH 'm*' } {34 50} #------------------------------------------------------------------------- # do_execsql_test 7.0 { BEGIN TRANSACTION; CREATE TABLE t7(docid PRIMARY KEY, a, b, c); CREATE INDEX i7 ON t7 USING fts5(); INSERT INTO t7 VALUES(1, 'a b c', 'd e f', 'a b c'); INSERT INTO t7 VALUES(2, 'x y z', 'a b c', 'a b c'); COMMIT; } foreach {tn expr res} { 1 {a} {1 2} 2 {a:a} {1} 3 {b:a} {2} 4 {c:a} {1 2} 5 {a:a*} {1} } { do_execsql_test 7.$tn {SELECT docid FROM t7 WHERE t7 MATCH $expr} $res } finish_test |