Index: openacs-4/packages/tsearch2-driver/sql/postgresql/tsearch2-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/sql/postgresql/Attic/tsearch2-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/tsearch2-driver/sql/postgresql/tsearch2-create.sql 6 Jun 2004 01:49:41 -0000 1.2 +++ openacs-4/packages/tsearch2-driver/sql/postgresql/tsearch2-create.sql 6 Jun 2004 20:03:33 -0000 1.3 @@ -17,4 +17,10 @@ ); create index fti_idx on txt using gist(fti); +create index object_id_idx on txt (object_id); +-- set to default configuration +-- user may set up additional dictionaries and change the config +-- there will be a parameter to select the config name + +select set_curcrg('default'); 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.2 -r1.3 --- openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl 6 Jun 2004 17:29:21 -0000 1.2 +++ openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl 6 Jun 2004 20:03:34 -0000 1.3 @@ -12,7 +12,7 @@ namespace eval tsearch2 {} -ad_proc -private tsearch2::index { +ad_proc -public tsearch2::index { object_id txt title @@ -35,15 +35,15 @@ } { set index_exists_p [db_0or1row object_exists "select 1 from txt where object_id=:object_id"] if {!$index_exists_p} { - db_dml index "insert into txt (object_id,fti) values ( :object_id, to_tsvector('default',:txt))" + db_dml index "insert into txt (object_id,fti) values ( :object_id, ts2_to_tsvector('default',:txt))" } else { tsearch2::update_index $object_id $txt $title $keywords } } -ad_proc -private tsearch2::unindex { +ad_proc -public tsearch2::unindex { object_id } { Remove item from FTS index @@ -60,7 +60,7 @@ db_dml unindex "delete from txt where object_id=:object_id" } -ad_proc -private tsearch2::update_index { +ad_proc -public tsearch2::update_index { object_id txt title @@ -83,14 +83,14 @@ } { set index_exists_p [db_0or1row object_exists "select 1 from txt where object_id=:object_id"] if {!$index_exists_p} { - db_dml index "insert into txt (object_id,fti) values ( :object_id, to_tsvector('default',:txt))" + db_dml index "insert into txt (object_id,fti) values ( :object_id, ts2_to_tsvector('default',:txt))" } else { - db_dml update_index "update txt set fti = to_tsvector('default',:txt) where object_id=:object_id" + db_dml update_index "update txt set fti = ts2_to_tsvector('default',:txt) where object_id=:object_id" } } -ad_proc -private tsearch2::search { +ad_proc -public tsearch2::search { query offset limit @@ -124,19 +124,19 @@ # turn and into & # turn or into | # turn not into ! - + set query [tsearch2::build_query -query $query] # FIXME actually write the regsub to do that, string map will # probably be too tricky to use - set results_ids [db_list search "select object_id from txt where fti @@ to_tsquery(:query) order by rank(fti,to_tsquery(:query));"] + set results_ids [db_list search "select object_id from txt where fti @@ ts2_to_tsquery('default',:query) order by rank(fti,ts2_to_tsquery('default',:query));"] set stop_words [list] # lovely the search package requires count to be returned but the # service contract definition doesn't specify it! return [list ids $results_ids stopwords $stop_words count [llength $results_ids]] } -ad_proc -private tsearch2::summary { +ad_proc -public tsearch2::summary { query txt } { @@ -153,10 +153,11 @@ @error } { - return [db_string summary "select headline(:txt,to_tsquery(:query))"] + set query [tsearch2::build_query -query $query] + return [db_string summary "select headline(:txt,ts2_to_tsquery('default',:query))"] } -ad_proc -private tsearch2::driver_info { +ad_proc -public tsearch2::driver_info { } { @@ -170,3 +171,21 @@ return [list package_key tsearch2-driver version 2 automatic_and_queries_p 0 stopwords_p 1] } +ad_proc -public tsearch2::build_query { + -query +} { + @author Dave Bauer (dave@thedesignexperience.org) + @creation-date 2004-06-05 + + @param query + + @return query formatted for passign to to_tsquery function + + @error + +} { + + set terms [split $query] + return [join $terms "&"] + +}