如何提取SQLite FTS表中的所有令牌? [英] How do you extract all the tokens in a SQLite FTS table?
问题描述
出于调试目的,我想查看SQLite中的全文本搜索虚拟表中存在的所有令牌.
For debugging purposes I want to see all the tokens that exist in a Full Text Search virtual table in SQLite.
当我查看FTS表(名为fts_table
)的数据库结构时,会看到以下内容:
When I look at the database structure for my FTS table (named fts_table
) I see the following:
但是浏览这些表中的数据不会显示令牌列表(无论如何我都找不到).
But browsing the data in these tables doesn't show the the list of tokens (not that I can find, anyway).
如何提取简单的令牌列表?
How do I extract a simple list of tokens?
推荐答案
您可以使用 ftx4aux
,可以直接访问全文本索引.
You can do this with ftx4aux
, which gives direct access to the full text index.
使用以下SQLite命令:
Use the following SQLite commands:
CREATE VIRTUAL TABLE search_terms USING fts4aux(fts_table);
SELECT term FROM search_terms WHERE col='*';
阅读文档以更好地了解其工作原理,但是term
列基本上存储令牌,并且col
列中的每个星号(*)实例都是唯一的术语.
Read the documentation for a better understanding of how this works, but basically the term
column stores the tokens and every instance of an asterisk (*) in the col
column is a unique term.
如果您需要将其导出到文本文件,则可以从命令行 进行以下操作:
If you need to export this to a text file, you can do something like this from the command line:
sqlite> .mode csv
sqlite> .output test.csv
sqlite> SELECT term FROM search_terms WHERE col='*';
sqlite> .output stdout
另请参阅:
- SQLite FTS3 and FTS4 Extensions
- The Spellfix1 Virtual Table
- Command Line Shell For SQLite
这篇关于如何提取SQLite FTS表中的所有令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!