Index: openacs-4/packages/search/search.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/search.info,v diff -u -r1.3 -r1.4 --- openacs-4/packages/search/search.info 18 Oct 2001 21:06:09 -0000 1.3 +++ openacs-4/packages/search/search.info 2 Jul 2002 01:52:38 -0000 1.4 @@ -9,6 +9,7 @@ + oracle postgresql Neophytos Demetriou @@ -17,6 +18,14 @@ + + + + + + + + @@ -26,7 +35,10 @@ + + + Index: openacs-4/packages/search/sql/oracle/search-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-create.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1,3 @@ +@@ search-tables-create.sql +@@ search-packages-create.sql +@@ search-sc-create.sql Index: openacs-4/packages/search/sql/oracle/search-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-drop.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1,3 @@ +@@ search-sc-drop.sql +@@ search-packages-drop.sql +@@ search-tables-drop.sql Index: openacs-4/packages/search/sql/oracle/search-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-packages-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-packages-create.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1,59 @@ +-- +-- Search Observer +-- + +create or replace package search_observer +as + + procedure enqueue ( + object_id in search_observer_queue.object_id%TYPE, + event in search_observer_queue.event%TYPE + ); + + procedure dequeue ( + object_id in search_observer_queue.object_id%TYPE, + event_date in search_observer_queue.event_date%TYPE, + event in search_observer_queue.event%TYPE + ); + +end search_observer; +/ +show errors + +create or replace package body search_observer +as + + procedure enqueue ( + object_id in search_observer_queue.object_id%TYPE, + event in search_observer_queue.event%TYPE + ) + is + begin + + insert + into search_observer_queue + (object_id, event) + values + (enqueue.object_id, enqueue.event); + + end enqueue; + + procedure dequeue ( + object_id in search_observer_queue.object_id%TYPE, + event_date in search_observer_queue.event_date%TYPE, + event in search_observer_queue.event%TYPE + ) + is + begin + + delete + from search_observer_queue + where object_id = dequeue.object_id + and event = dequeue.event + and event_date = dequeue.event_date; + + end dequeue; + +end search_observer; +/ +show errors Index: openacs-4/packages/search/sql/oracle/search-packages-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-packages-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-packages-drop.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1,2 @@ +drop package body search_observer; +drop package search_observer; Index: openacs-4/packages/search/sql/oracle/search-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-sc-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-sc-create.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1,185 @@ +declare + foo integer; +begin + + -- + -- ACS-SC Contract: FtsEngineDriver + -- + + foo := acs_sc_contract.new( + contract_name => 'FtsEngineDriver', + contract_desc => 'Full Text Search Engine Driver' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Search.InputType', + msg_type_spec => 'query:string,offset:integer,limit:integer,user_id:integer,df:timestamp,dt:timestamp' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Search.OutputType', + msg_type_spec => 'ids:integer[],stopwords:string[]' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsEngineDriver', + operation_name => 'search', + operation_desc => 'Search', + operation_iscachable_p => 'f', + operation_nargs => 6, + operation_inputtype => 'FtsEngineDriver.Search.InputType', + operation_outputtype => 'FtsEngineDriver.Search.OutputType' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Index.InputType', + msg_type_spec => 'object_id:integer,txt:string,title:string,keywords:string' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Index.OutputType', + msg_type_spec => '' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsEngineDriver', + operation_name => 'index', + operation_desc => 'Index', + operation_iscachable_p => 'f', + operation_nargs => 4, + operation_inputtype => 'FtsEngineDriver.Index.InputType', + operation_outputtype => 'FtsEngineDriver.Index.OutputType' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Unindex.InputType', + msg_type_spec => 'object_id:integer' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Unindex.OutputType', + msg_type_spec => '' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsEngineDriver', + operation_name => 'unindex', + operation_desc => 'Unindex', + operation_iscachable_p => 'f', + operation_nargs => 1, + operation_inputtype => 'FtsEngineDriver.Unindex.InputType', + operation_outputtype => 'FtsEngineDriver.Unindex.OutputType' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.UpdateIndex.InputType', + msg_type_spec => 'object_id:integer,txt:string,title:string,keywords:string' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.UpdateIndex.OutputType', + msg_type_spec => '' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsEngineDriver', + operation_name => 'update_index', + operation_desc => 'Update Index', + operation_iscachable_p => 'f', + operation_nargs => 4, + operation_inputtype => 'FtsEngineDriver.UpdateIndex.InputType', + operation_outputtype => 'FtsEngineDriver.UpdateIndex.OutputType' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Summary.InputType', + msg_type_spec => 'query:string,txt:string' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Summary.OutputType', + msg_type_spec => 'summary:string' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsEngineDriver', + operation_name => 'summary', + operation_desc => 'Summary', + operation_iscachable_p => 'f', + operation_nargs => 2, + operation_inputtype => 'FtsEngineDriver.Summary.InputType', + operation_outputtype => 'FtsEngineDriver.Summary.OutputType' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Info.InputType', + msg_type_spec => '' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsEngineDriver.Info.OutputType', + msg_type_spec => 'package_key:string,version:version,automatic_and_queries_p:boolean,stopwords_p:boolean' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsEngineDriver', + operation_name => 'info', + operation_desc => 'Information about the driver', + operation_iscachable_p => 'f', + operation_nargs => 1, + operation_inputtype => 'FtsEngineDriver.Info.InputType', + operation_outputtype => 'FtsEngineDriver.Info.OutputType' + ); + + -- + -- ACS-SC Contract: FtsContentProvider + -- + + foo := acs_sc_contract.new( + contract_name => 'FtsContentProvider', + contract_desc => 'Full Text Search Content Provider' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsContentProvider.Datasource.InputType', + msg_type_spec => 'object_id:integer' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsContentProvider.Datasource.OutputType', + msg_type_spec => 'object_id:integer,title:string,content:string,mime:string,storage_type:string' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsContentProvider', + operation_name => 'datasource', + operation_desc => 'Data Source', + operation_iscachable_p => 'f', + operation_nargs => 1, + operation_inputtype => 'FtsContentProvider.Datasource.InputType', + operation_outputtype => 'FtsContentProvider.Datasource.OutputType' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsContentProvider.Url.InputType', + msg_type_spec => 'object_id:integer' + ); + + foo := acs_sc_msg_type.new( + msg_type_name => 'FtsContentProvider.Url.OutputType', + msg_type_spec => 'url:uri' + ); + + foo := acs_sc_operation.new( + contract_name => 'FtsContentProvider', + operation_name => 'url', + operation_desc => 'URL', + operation_iscachable_p => 'f', + operation_nargs => 1, + operation_inputtype => 'FtsContentProvider.Url.InputType', + operation_outputtype => 'FtsContentProvider.Url.OutputType' + ); + +end; +/ +show errors Index: openacs-4/packages/search/sql/oracle/search-sc-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-sc-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-sc-drop.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1,26 @@ +declare +begin + + acs_sc_contract.delete(contract_name => 'FtsContentProvider'); + acs_sc_msg_type.delete(msg_type_name => 'FtsContentProvider.Datasource.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsContentProvider.Datasource.OutputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsContentProvider.Url.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsContentProvider.Url.OutputType'); + + acs_sc_contract.delete(contract_name => 'FtsEngineDriver'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Search.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Search.OutputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Index.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Index.OutputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Unindex.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Unindex.OutputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.UpdateIndex.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.UpdateIndex.OutputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Summary.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Summary.OutputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Info.InputType'); + acs_sc_msg_type.delete(msg_type_name => 'FtsEngineDriver.Info.OutputType'); + +end; +/ +show errors Index: openacs-4/packages/search/sql/oracle/search-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-tables-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-tables-create.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1,8 @@ +create table search_observer_queue ( + object_id integer, + event_date date + default sysdate, + event varchar(6) + constraint search_observer_queue_event_ck + check (event in ('INSERT','DELETE','UPDATE')) +); Index: openacs-4/packages/search/sql/oracle/search-tables-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-tables-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/search-tables-drop.sql 2 Jul 2002 01:52:38 -0000 1.1 @@ -0,0 +1 @@ +drop table search_observer_queue; Index: openacs-4/packages/search/sql/postgresql/search-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/search-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/search/sql/postgresql/search-drop.sql 2 Sep 2001 18:11:39 -0000 1.1 +++ openacs-4/packages/search/sql/postgresql/search-drop.sql 2 Jul 2002 01:52:39 -0000 1.2 @@ -1,3 +1,3 @@ \i search-sc-drop.sql \i search-packages-drop.sql -\i search-tables-drop.sql \ No newline at end of file +\i search-tables-drop.sql Index: openacs-4/packages/search/sql/postgresql/search-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/search-packages-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/search/sql/postgresql/search-packages-create.sql 2 Sep 2001 18:11:39 -0000 1.1 +++ openacs-4/packages/search/sql/postgresql/search-packages-create.sql 2 Jul 2002 01:52:39 -0000 1.2 @@ -25,14 +25,14 @@ returns integer as ' declare p_object_id alias for $1; - p_date alias for $2; + p_event_date alias for $2; p_event alias for $3; begin delete from search_observer_queue where object_id = p_object_id - and date =p_date - and event = p_event; + and event = p_event + and event_date = p_event_date; return 0; Index: openacs-4/packages/search/sql/postgresql/search-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/search-tables-create.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/search/sql/postgresql/search-tables-create.sql 15 Sep 2001 21:31:50 -0000 1.4 +++ openacs-4/packages/search/sql/postgresql/search-tables-create.sql 2 Jul 2002 01:52:39 -0000 1.5 @@ -1,6 +1,6 @@ create table search_observer_queue ( object_id integer, - date timestamp default now(), + event_date timestamp default now(), event varchar(6) constraint search_observer_queue_event_ck check (event in ('INSERT','DELETE','UPDATE')) Index: openacs-4/packages/search/tcl/search-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/tcl/search-procs-oracle.xql 2 Jul 2002 01:52:39 -0000 1.1 @@ -0,0 +1,19 @@ + + + + postgresql>7.1 + + + + declare + begin + search_observer.dequeue( + object_id => :object_id, + date => :date, + event => :event + ); + end; + + + + Index: openacs-4/packages/search/tcl/search-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/Attic/search-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/tcl/search-procs-postgresql.xql 2 Jul 2002 01:52:39 -0000 1.1 @@ -0,0 +1,16 @@ + + + + postgresql>7.1 + + + + select search_observer__dequeue( + :object_id, + :date, + :event + ); + + + + Index: openacs-4/packages/search/tcl/search-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/search/tcl/search-procs.tcl 13 Mar 2002 22:50:53 -0000 1.7 +++ openacs-4/packages/search/tcl/search-procs.tcl 2 Jul 2002 01:52:39 -0000 1.8 @@ -1,55 +1,55 @@ +ad_library { + + full-text search engine + + @author Neophytos Demetriou (k2pts@yahoo.com) + @version $Id$ + +} + ad_proc search_indexer {} { @author Neophytos Demetriou } { set driver [ad_parameter -package_id [apm_package_id_from_key search] FtsEngineDriver] - db_foreach search_observer_queue_entry { - select object_id, date, event - from search_observer_queue - order by date asc - } { + db_foreach search_observer_queue_entry {} { - switch $event { - INSERT { - set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] - if [acs_sc_binding_exists_p FtsContentProvider $object_type] { - array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] - search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) - acs_sc_call FtsEngineDriver index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver - } - # Remember seeing this object so we can avoid reindexing it later - set seen($object_id) 1 - } - DELETE { - acs_sc_call FtsEngineDriver unindex [list $object_id] $driver - } - UPDATE { - # Don't bother reindexing if we've already inserted/updated this object in this run - if { ![info exists seen($object_id)] } { - set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] - if [acs_sc_binding_exists_p FtsContentProvider $object_type] { - array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] - search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) - acs_sc_call FtsEngineDriver update_index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver - } - # Remember seeing this object so we can avoid reindexing it later - set seen($object_id) 1 - } - } - } + switch $event { + INSERT { + set object_type [acs_object_type $object_id] + if {[acs_sc_binding_exists_p FtsContentProvider $object_type]} { + array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] + search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) + acs_sc_call FtsEngineDriver index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver + } + # Remember seeing this object so we can avoid reindexing it later + set seen($object_id) 1 + } + DELETE { + acs_sc_call FtsEngineDriver unindex [list $object_id] $driver + } + UPDATE { + # Don't bother reindexing if we've already inserted/updated this object in this run + if {![info exists seen($object_id)]} { + set object_type [acs_object_type $object_id] + if {[acs_sc_binding_exists_p FtsContentProvider $object_type]} { + array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] + search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) + acs_sc_call FtsEngineDriver update_index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver + } + # Remember seeing this object so we can avoid reindexing it later + set seen($object_id) 1 + } + } + } - db_exec_plsql search_observer_dequeue_entry { - select search_observer__dequeue( - :object_id, - :date, - :event - ); - } + db_exec_plsql search_observer_dequeue_entry {} + } + } - ad_proc search_content_get { _txt content @@ -58,7 +58,7 @@ } { @author Neophytos Demetriou - @param content + @param content holds the filename if storage_type=file holds the text data if storage_type=text holds the lob_id if storage_type=lob @@ -68,25 +68,22 @@ set txt "" switch $storage_type { - text { - set data $content - } - file { - set data [db_blob_get data "select '$content' as content, 'file' as storage_type"] - } - lob { + text { + set data $content + } + file { + set data [db_blob_get get_file_data {}] + } + lob { db_transaction { - set data [db_blob_get data "select $content as content, 'lob' as storage_type"] + set data [db_blob_get get_lob_data {}] } - } + } } search_content_filter txt data $mime - } - - ad_proc search_content_filter { _txt _data @@ -98,19 +95,15 @@ upvar $_data data switch $mime { - {text/plain} { - set txt $data - } - {text/html} { - set txt $data - } + {text/plain} { + set txt $data + } + {text/html} { + set txt $data + } } } - - - - ad_proc search_choice_bar { items links values {default ""} } { @author Neophytos Demetriou } { @@ -119,23 +112,19 @@ set return_list [list] foreach value $values { - if { [string compare $default $value] == 0 } { - lappend return_list "[lindex $items $count]" + if {[string compare $default $value] == 0} { + lappend return_list "[lindex $items $count]" } else { - lappend return_list "[lindex $items $count]" + lappend return_list "[lindex $items $count]" } incr count } - if { [llength $return_list] > 0 } { + if {[llength $return_list] > 0} { return "[join $return_list " "]" } else { return "" } - -} - - - +} Index: openacs-4/packages/search/tcl/search-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/tcl/search-procs.xql 2 Jul 2002 01:52:39 -0000 1.1 @@ -0,0 +1,29 @@ + + + + + + + select object_id, date, event + from search_observer_queue + order by date asc + + + + + + select ':content' as content, + 'file' as storage_type + from dual + + + + + + select :content as content, + 'lob' as storage_type + from dual + + + + Index: openacs-4/packages/search/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/search.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/search/www/search.tcl 20 Sep 2001 01:10:56 -0000 1.6 +++ openacs-4/packages/search/www/search.tcl 2 Jul 2002 01:52:39 -0000 1.7 @@ -60,7 +60,7 @@ if { $t == "Feeling Lucky" && $result(count) > 0} { set object_id [lindex $result(ids) 0] - set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] + set object_type [acs_object_type $object_id] set url [acs_sc_call FtsContentProvider url [list $object_id] $object_type] ad_returnredirect $url return @@ -101,7 +101,7 @@ for { set __i 0 } { $__i < [expr $high - $low +1] } { incr __i } { set object_id [lindex $result(ids) $__i] - set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] + set object_type [acs_object_type $object_id] array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) set title_summary [acs_sc_call FtsEngineDriver summary [list $q $datasource(title)] $driver] @@ -174,9 +174,3 @@ ]] ns_write $template_bottom - - - - - -