From aaf28d160311e9af3585511cb3bd1f826b22e9db Mon Sep 17 00:00:00 2001 From: Barnik Roy Date: Wed, 3 Jan 2024 11:28:09 +0530 Subject: [PATCH] Update zimply.py Addresses the disabled fts4 (fts5 enabled by default) problem by updating to the fts5 syntax (fixes #36) --- zimply/zimply.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zimply/zimply.py b/zimply/zimply.py index 89ad2a8..530a9a5 100644 --- a/zimply/zimply.py +++ b/zimply/zimply.py @@ -783,7 +783,7 @@ def on_get(self, request, response): cursor = ZIMRequestHandler.reverse_index.cursor() search_for = "* ".join(keywords) + "*" - cursor.execute("SELECT docid FROM papers WHERE title MATCH ?", + cursor.execute("SELECT rowid FROM papers WHERE title MATCH ?", [search_for]) results = cursor.fetchall() @@ -886,16 +886,16 @@ def _bootstrap(self, index_file): cursor = db.cursor() # limit memory usage to 64MB cursor.execute("PRAGMA CACHE_SIZE = -65536") - # create a contentless virtual table using full-text search (FTS4) + # create a contentless virtual table using full-text search (FTS5) # and the porter tokeniser cursor.execute("CREATE VIRTUAL TABLE papers " - "USING fts4(content='', title, tokenize=porter);") + "USING fts5(content='', title, tokenize=porter);") # get an iterator to access all the articles articles = iter(self._zim_file) for url, title, idx in articles: # retrieve articles one by one cursor.execute( - "INSERT INTO papers(docid, title) VALUES (?, ?)", + "INSERT INTO papers(rowid, title) VALUES (?, ?)", (idx, title)) # and add them # once all articles are added, commit the changes to the database db.commit()