diff roundup/backends/indexer_common.py @ 6588:91ab3e0ffcd0

Summary: Add test cases for sqlite fts Add support for using the FTS5 full text query engine for sqlite. Also stubbed out some sections for adding postgresql FTS support as well. Added nee indexer type native-fts. It is not selected by default. The indexer=native is used if no indexer is set. This prevents an upgrade from seeming to wipe out the native index if upgraded and indexer=native is not explicitly set. Docs updated. Also changed section headers to sentence case for the current release notes. Indexing backend can control if the full text search phrase is broken into a list of words or passed intact. For backends with query languages (sqlite and can be enabled for whoosh and xapian) we do not want the phrase "tokenized" on whitespace. This also updates the rdbms database version to version 7 to add FTS table. I will be using the same version when I add postgresql. If somebody runs this version on postgresql, they will have to manually add the fts tables for postgresql if they want to use it. Added a new renderError method to client. This allows errors to be reported still using page.html rather than raw html. It also supports templates for any error code. If no template for the error code (e.g. 400) is found, the error in raw html with no page frame is shown. New IndexerQueryError exception to pass back message about query syntax errors.
author John Rouillard <rouilj@ieee.org>
date Sun, 23 Jan 2022 18:57:45 -0500
parents 9d209d2b34ae
children 39189dd94f2c
line wrap: on
line diff
--- a/roundup/backends/indexer_common.py	Sat Jan 22 01:33:06 2022 -0500
+++ b/roundup/backends/indexer_common.py	Sun Jan 23 18:57:45 2022 -0500
@@ -24,6 +24,9 @@
         self.minlength = 2
         self.maxlength = 25
         self.language = db.config[('main','indexer_language')]
+        # Some indexers have a query language. If that is the case,
+        # we don't parse the user supplied query into a wordlist.
+        self.query_language = False
 
     def is_stopword(self, word):
         return word in self.stopwords
@@ -134,6 +137,19 @@
         from .indexer_whoosh import Indexer
         return Indexer(db)
 
+    if indexer_name == "native-fts":
+        if db.dbtype not in ("sqlite", "postgres"):
+            raise AssertionError("Indexer native-fts is configured, but only sqlite and postgres support it. Database is: %r" % db.dbtype)
+
+        if db.dbtype == "sqlite":
+            from roundup.backends.indexer_sqlite_fts import Indexer
+            return Indexer(db)
+
+        if db.dbtype == "postgres":
+            raise NotImplementedError("Postgres FTS not available")
+            from roundup.backends.indexer_postgres_fts import Indexer
+            return Indexer(db)
+
     if indexer_name == "native":
         # load proper native indexing based on database type
         if db.dbtype == "anydbm":

Roundup Issue Tracker: http://roundup-tracker.org/