Skip to content

Commit

Permalink
Update zimply.py
Browse files Browse the repository at this point in the history
Addresses the disabled fts4 (fts5 enabled by default) problem by updating to the fts5 syntax (fixes kimbauters#36)
  • Loading branch information
aeryskyB authored Jan 3, 2024
1 parent 03fca8a commit aaf28d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions zimply/zimply.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit aaf28d1

Please sign in to comment.