mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 12:44:10 +00:00
* fix: align fulltext bloom tokens with matches_term and use them for LIKE The bloom fulltext index stored tokens that did not follow matches_term's word boundaries (`_`, ASCII next to Han, Han substrings), so pruning dropped rows matches_term accepts. Tokens and query probes now share the character classes of matches_term, Han runs are indexed as bigrams, and LIKE patterns use the same probes. The bloom blob is written under a new key; blobs from older versions are no longer probed. Tantivy no longer serves matches_term. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * chore: drop unused lazy_static from index and avoid typo-flagged test tokens Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs: link like_probes to tokenize instead of the downstream ScriptTokenizer Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor: name probe extraction with verbs and document CharClass Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat: rebuild legacy fulltext bloom indexes and probe lower(col) The manifest records the fulltext bloom version per column, so ADMIN BUILD_INDEX now rebuilds SSTs whose bloom index predates the current tokens, and ssts_index_meta shows the version. Case-insensitive bloom indexes also store the tokens of the whole lowercased text for rows where it can differ (U+0130, U+212A, sigma), so matches_term(lower(col), ..) and lower(col) LIKE .. use the index. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test: cover legacy bloom index rewrite by compaction in the compat case Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * chore: log outdated fulltext bloom indexes in the consistency check Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs: explain the unrecorded fulltext bloom version Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
72 lines
2.7 KiB
SQL
72 lines
2.7 KiB
SQL
-- Only the SST written by the old binary.
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg @@ 'world' ORDER BY ts;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg @@ 'error' ORDER BY ts;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg @@ '农业' ORDER BY ts;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg LIKE 'hello\_%' ORDER BY ts;
|
|
|
|
INSERT INTO t_fulltext_bloom_tokens VALUES
|
|
(4, 'hello_world again'),
|
|
(5, '农业 error');
|
|
|
|
ADMIN FLUSH_TABLE('t_fulltext_bloom_tokens');
|
|
|
|
-- Old and new SSTs: one bloom blob of each version.
|
|
SELECT meta_json LIKE '%"bloom_version":2%' AS is_v2, count(*) AS ssts
|
|
FROM information_schema.ssts_index_meta
|
|
WHERE table_id = (SELECT table_id FROM information_schema.tables WHERE table_name = 't_fulltext_bloom_tokens')
|
|
AND index_type = 'fulltext_bloom'
|
|
GROUP BY is_v2
|
|
ORDER BY is_v2;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg @@ 'world' ORDER BY ts;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg @@ 'error' ORDER BY ts;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg @@ '农业' ORDER BY ts;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg LIKE 'hello\_%' ORDER BY ts;
|
|
|
|
-- Rebuilds the old SST's index with the current bloom version.
|
|
ADMIN BUILD_INDEX('t_fulltext_bloom_tokens');
|
|
|
|
-- SQLNESS SLEEP 2s
|
|
SELECT meta_json LIKE '%"bloom_version":2%' AS is_v2, count(*) AS ssts
|
|
FROM information_schema.ssts_index_meta
|
|
WHERE table_id = (SELECT table_id FROM information_schema.tables WHERE table_name = 't_fulltext_bloom_tokens')
|
|
AND index_type = 'fulltext_bloom'
|
|
GROUP BY is_v2
|
|
ORDER BY is_v2;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_tokens WHERE msg @@ 'world' ORDER BY ts;
|
|
|
|
DROP TABLE t_fulltext_bloom_tokens;
|
|
|
|
-- Two SSTs written by the old binary.
|
|
SELECT meta_json LIKE '%"bloom_version":2%' AS is_v2, count(*) AS ssts
|
|
FROM information_schema.ssts_index_meta
|
|
WHERE table_id = (SELECT table_id FROM information_schema.tables WHERE table_name = 't_fulltext_bloom_compact')
|
|
AND index_type = 'fulltext_bloom'
|
|
GROUP BY is_v2
|
|
ORDER BY is_v2;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_compact WHERE msg @@ 'world' ORDER BY ts;
|
|
|
|
-- Merges both SSTs into one with a current bloom blob.
|
|
ADMIN COMPACT_TABLE('t_fulltext_bloom_compact', 'strict_window', 'window=3600');
|
|
|
|
SELECT meta_json LIKE '%"bloom_version":2%' AS is_v2, count(*) AS ssts
|
|
FROM information_schema.ssts_index_meta
|
|
WHERE table_id = (SELECT table_id FROM information_schema.tables WHERE table_name = 't_fulltext_bloom_compact')
|
|
AND index_type = 'fulltext_bloom'
|
|
GROUP BY is_v2
|
|
ORDER BY is_v2;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_compact WHERE msg @@ 'world' ORDER BY ts;
|
|
|
|
SELECT ts, msg FROM t_fulltext_bloom_compact WHERE msg @@ '农业' ORDER BY ts;
|
|
|
|
DROP TABLE t_fulltext_bloom_compact;
|