Index: openacs-4/packages/tsearch2-driver/tsearch2-driver.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/tsearch2-driver.info,v diff -u -r1.19.2.3 -r1.19.2.4 --- openacs-4/packages/tsearch2-driver/tsearch2-driver.info 24 Feb 2021 12:51:17 -0000 1.19.2.3 +++ openacs-4/packages/tsearch2-driver/tsearch2-driver.info 30 Apr 2021 17:42:53 -0000 1.19.2.4 @@ -9,14 +9,14 @@ f t - + Dave Bauer Full text search support for Search via Tsearch2. 2017-08-06 Provides an implementation for the search packages service contract for searching on PostgreSQL. 3 - + Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/tsearch2-driver/sql/postgresql/upgrade/upgrade-5.10.0d5-5.10.0d6.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-install-procs.tcl,v diff -u -r1.9.2.3 -r1.9.2.4 --- openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-install-procs.tcl 6 Mar 2021 19:22:48 -0000 1.9.2.3 +++ openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-install-procs.tcl 30 Apr 2021 17:42:53 -0000 1.9.2.4 @@ -99,7 +99,7 @@ search tsearch2::search index tsearch2::index unindex tsearch2::unindex - update_index tsearch2::update_index + update_index tsearch2::index summary tsearch2::summary info tsearch2::driver_info } Index: openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs-postgresql.xql,v diff -u -r1.13.2.3 -r1.13.2.4 --- openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs-postgresql.xql 18 May 2020 20:46:41 -0000 1.13.2.3 +++ openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs-postgresql.xql 30 Apr 2021 17:42:53 -0000 1.13.2.4 @@ -1,14 +1,24 @@ - postgresql8.3 - insert into txt (object_id,fti) - select object_id, - setweight(to_tsvector(coalesce(:title,'')),'A') - ||setweight(to_tsvector(coalesce(:keywords,'')),'B') - ||to_tsvector(coalesce(:txt,'')) - from acs_objects where object_id = :object_id + with index as ( + select setweight(to_tsvector(coalesce(:title,'')),'A') + ||setweight(to_tsvector(coalesce(:keywords,'')),'B') + ||to_tsvector(coalesce(:txt,'')) as fti + from dual + ), + insert as ( + insert into txt (object_id, fti) + select o.object_id, i.fti + from acs_objects o, index i + where object_id = :object_id + and not exists (select 1 from txt + where object_id = o.object_id) + ) + update txt set + fti = (select fti from index) + where object_id = :object_id @@ -76,17 +86,6 @@ - - postgresql8.3 - - update txt set fti = - setweight(to_tsvector(coalesce(:title,'')),'A') - ||setweight(to_tsvector(coalesce(:keywords,'')),'B') - ||to_tsvector(coalesce(:txt,'')) - where object_id=:object_id - - - postgresql8.2 Index: openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl,v diff -u -r1.41.2.7 -r1.41.2.8 --- openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl 6 Mar 2021 19:22:48 -0000 1.41.2.7 +++ openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl 30 Apr 2021 17:42:53 -0000 1.41.2.8 @@ -37,7 +37,7 @@ title keywords } { - add object to full text index + Add or update an object in the full text index. @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2004-06-05 @@ -49,13 +49,8 @@ @return nothing } { - set index_exists_p [db_0or1row object_exists "select 1 from txt where object_id=:object_id"] - if {!$index_exists_p} { - set txt [tsearch2::trunc_to_max $txt] - db_dml index {} - } else { - tsearch2::update_index $object_id $txt $title $keywords - } + set txt [tsearch2::trunc_to_max $txt] + db_dml index {} } ad_proc -public tsearch2::unindex { @@ -73,14 +68,13 @@ db_dml unindex "delete from txt where object_id=:object_id" } -ad_proc -public tsearch2::update_index { - object_id - txt - title - keywords -} { +ad_proc -deprecated tsearch2::update_index args { update full text index + DEPRECATED: modern SQL supports upsert idioms + + @see tsearch2::index + @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2004-06-05 @@ -91,13 +85,7 @@ @return nothing } { - set index_exists_p [db_0or1row object_exists "select 1 from txt where object_id=:object_id"] - if {!$index_exists_p} { - tsearch2::index $object_id $txt $title $keywords - } else { - set txt [tsearch2::trunc_to_max $txt] - db_dml update_index "" - } + tsearch2::index {*}$args } ad_proc -callback search::search -impl tsearch2-driver { Index: openacs-4/packages/tsearch2-driver/tcl/test/tsearch2-driver-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/tcl/test/tsearch2-driver-procs.tcl,v diff -u -r1.5.2.9 -r1.5.2.10 --- openacs-4/packages/tsearch2-driver/tcl/test/tsearch2-driver-procs.tcl 25 Feb 2021 17:39:42 -0000 1.5.2.9 +++ openacs-4/packages/tsearch2-driver/tcl/test/tsearch2-driver-procs.tcl 30 Apr 2021 17:42:53 -0000 1.5.2.10 @@ -141,7 +141,6 @@ } -procs { tsearch2::index tsearch2::unindex - tsearch2::update_index } index_unindex { Test indexing/unindexing } { @@ -176,7 +175,7 @@ set txt "This is just a test object with edited text" set title "Test object updated" set keywords "test foo bar monger" - tsearch2::update_index $object_id $txt $title $keywords + tsearch2::index $object_id $txt $title $keywords # # Check if the keywords have been updated in the index #