0

这个问题涉及如何将 FTS5 的 trigram tokenizer 与 Peewee 一起使用。

  1. SQLite的 官方 FTS5 文档引用了对 trigram 标记化/相似性的支持

     > 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');
    
  2. 我试过用 Peewee 建立一个基于 FTS 的课程。我更改了使用 trigram 标记器的选项:

     class Meta:
         db_table = 'fts_test_db'
         database = test_db
         options = {'tokenize': 'trigram', 'content': PrecedentPW}
    
  3. 当我尝试使用这些选项创建表时,此错误会翻转:

     _db.create_tables([_fts], )
    
     >> peewee.OperationalError: no such tokenizer: trigram
    
  4. 但是,如果我更改标记器选项以使用其他东西(例如“搬运工”),则不会引发错误。

如何将 trigram tokenizer 与 Peewee 一起使用?

4

1 回答 1

1

您可能需要自己编译标记器或确保您运行的是足够新的版本。在 Sqlite 3.34.0 之前,默认情况下不包含 trigram 标记器:https ://www.sqlite.org/releaselog/3_34_0.html

于 2021-10-18T14:27:19.223 回答