How do you extract all the tokens in a SQLite FTS table?

谁都会走 提交于 2020-01-02 23:15:25

问题


For debugging purposes I want to see all the tokens that exist in a Full Text Search virtual table in SQLite.

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?


回答1:


You can do this with ftx4aux, which gives direct access to the full text index.

Use the following SQLite commands:

CREATE VIRTUAL TABLE search_terms USING fts4aux(fts_table);
SELECT term FROM search_terms WHERE 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

See also:

  • SQLite FTS3 and FTS4 Extensions
  • The Spellfix1 Virtual Table
  • Command Line Shell For SQLite


来源:https://stackoverflow.com/questions/29997385/how-do-you-extract-all-the-tokens-in-a-sqlite-fts-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!