【发布时间】:2021-10-17 13:33:53
【问题描述】:
这个问题涉及如何将 FTS5 的 trigram tokenizer 与 Peewee 一起使用。
-
official FTS5 documentation for SQLite cites support for trigram tokenization/similarity:
> The experimental trigram tokenizer extends FTS5 to > support substring matching in general, instead of the > usual token matching. When using the trigram tokenizer > , a query or phrase token may match any sequence of > characters within a row, not just a complete token. > > CREATE VIRTUAL TABLE tri USING fts5(a, tokenize="trigram"); > INSERT INTO tri VALUES('abcdefghij KLMNOPQRST uvwxyz'); -
我尝试使用 Peewee 设置基于 FTS 的课程。我更改了使用 trigram 标记器的选项:
class Meta: db_table = 'fts_test_db' database = test_db options = {'tokenize': 'trigram', 'content': PrecedentPW} -
当我尝试使用这些选项创建表时,会出现此错误:
_db.create_tables([_fts], ) >> peewee.OperationalError: no such tokenizer: trigram -
但是,如果我将标记器选项更改为使用其他东西(例如“搬运工”),则不会引发错误。
如何在 Peewee 中使用 trigram 标记器?
【问题讨论】: