Explicitly specify the tsearch configuration to use
authorMagnus Hagander <magnus@hagander.net>
Sun, 2 Apr 2017 13:15:21 +0000 (15:15 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sun, 2 Apr 2017 13:15:21 +0000 (15:15 +0200)
The main reason this didn't work before was because of server dictionary
configuration, not because of the code. But make it explicit so we're
not relying on session level settings.

tools/search/crawler/lib/basecrawler.py
tools/search/sql/functions.sql

index 62934c6d8b819fd45dbcf651e3295b7e00290406..6254f45c056cdfbefd40d83e73539b176259c72a 100644 (file)
@@ -147,9 +147,9 @@ class BaseSiteCrawler(object):
                        'internal': internal,
                        }
                curs = self.dbconn.cursor()
-               curs.execute("UPDATE webpages SET title=%(title)s, txt=%(txt)s, fti=to_tsvector(%(txt)s), lastscanned=%(lastmod)s, relprio=%(relprio)s, isinternal=%(internal)s WHERE site=%(site)s AND suburl=%(url)s", params)
+               curs.execute("UPDATE webpages SET title=%(title)s, txt=%(txt)s, fti=to_tsvector('public.pg', %(txt)s), lastscanned=%(lastmod)s, relprio=%(relprio)s, isinternal=%(internal)s WHERE site=%(site)s AND suburl=%(url)s", params)
                if curs.rowcount != 1:
-                       curs.execute("INSERT INTO webpages (site, suburl, title, txt, fti, lastscanned, relprio, isinternal) VALUES (%(site)s, %(url)s, %(title)s, %(txt)s, to_tsvector(%(txt)s), %(lastmod)s, %(relprio)s, %(internal)s)", params)
+                       curs.execute("INSERT INTO webpages (site, suburl, title, txt, fti, lastscanned, relprio, isinternal) VALUES (%(site)s, %(url)s, %(title)s, %(txt)s, to_tsvector('public.pg', %(txt)s), %(lastmod)s, %(relprio)s, %(internal)s)", params)
                        with self.counterlock:
                                self.pages_new += 1
                else:
index 6572b960fcaa682e0f36c5b903df080b3486bad8..4a0ba1c3a9107f2b6c1965f8122a1e75874daeea 100644 (file)
@@ -71,7 +71,7 @@ DECLARE
     curs refcursor;
     pagecount int;
 BEGIN
-    tsq := plainto_tsquery(query);
+    tsq := plainto_tsquery('public.pg', query);
     IF numnode(tsq) = 0 THEN
         siteid = 0;baseurl=NULL;suburl=NULL;title=NULL;headline=NULL;rank=0;
         RETURN NEXT;
@@ -106,7 +106,3 @@ BEGIN
 END;
 $$
 LANGUAGE 'plpgsql';
-/* Seems broken, so stop doing this for now
- * ALTER FUNCTION site_search(text, int, int, bool, text, boolean) SET default_text_search_config = 'public.pg';
- */
-