Index: openacs-4/packages/intermedia-driver/tcl/intermedia-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/intermedia-driver/tcl/intermedia-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/intermedia-driver/tcl/intermedia-procs.tcl 29 Jan 2019 19:00:09 -0000 1.5 +++ openacs-4/packages/intermedia-driver/tcl/intermedia-procs.tcl 29 Jan 2019 19:06:26 -0000 1.6 @@ -6,37 +6,37 @@ Search Index Callback for Oracle Intermedia @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2005-06-12 - + } { # we want the datasource array reference in case we want to do something clever if {$datasource ne ""} { - upvar $datasource _datasource + upvar $datasource _datasource } set content "${title} ${content}" # if storage type is file, store the text in the site_wide_index table if {![db_string index_exists "select 1 from site_wide_index where object_id=:object_id" -default 0]} { - db_dml index "insert into site_wide_index - (object_id, object_name, package_id, relevant_date, community_id, indexed_content) - values - (:object_id, :title, :package_id, :relevant_date, :community_id, empty_clob() ) - returning indexed_content into :1" -clobs [list $content] + db_dml index "insert into site_wide_index + (object_id, object_name, package_id, relevant_date, community_id, indexed_content) + values + (:object_id, :title, :package_id, :relevant_date, :community_id, empty_clob() ) + returning indexed_content into :1" -clobs [list $content] } else { - # call the update index proc since this object is already indexed - callback -impl intermedia-driver search::update_index \ - -object_id $object_id \ - -content $content \ - -title $title \ - -keywords $keywords \ - -community_id $community_id \ - -relevant_date $relevant_date \ - -description $description \ - -datasource $datasource \ - -package_id $package_id + # call the update index proc since this object is already indexed + callback -impl intermedia-driver search::update_index \ + -object_id $object_id \ + -content $content \ + -title $title \ + -keywords $keywords \ + -community_id $community_id \ + -relevant_date $relevant_date \ + -description $description \ + -datasource $datasource \ + -package_id $package_id } - + } ad_proc -public -callback search::update_index -impl intermedia-driver {} { @@ -45,29 +45,29 @@ @creation-date 2005-08-01 } { if {$datasource ne ""} { - upvar $datasource _datasource - } + upvar $datasource _datasource + } if {![db_string index_exists "select 1 from site_wide_index where object_id=:object_id" -default 0]} { - callback -impl intermedia-driver search::index \ - -object_id $object_id \ - -content $content \ - -title $title \ - -keywords $keywords \ - -community_id $community_id \ - -relevant_date $relevant_date \ - -description $description \ - -datasource $datasource \ - -package_id $package_id - return + callback -impl intermedia-driver search::index \ + -object_id $object_id \ + -content $content \ + -title $title \ + -keywords $keywords \ + -community_id $community_id \ + -relevant_date $relevant_date \ + -description $description \ + -datasource $datasource \ + -package_id $package_id + return } else { - db_dml index "update site_wide_index - set object_name=:title, - package_id=:package_id, - community_id=:community_id, - relevant_date=:relevant_date, - indexed_content=empty_clob() - where object_id=:object_id - returning indexed_content into :1" -clobs [list $content] + db_dml index "update site_wide_index + set object_name=:title, + package_id=:package_id, + community_id=:community_id, + relevant_date=:relevant_date, + indexed_content=empty_clob() + where object_id=:object_id + returning indexed_content into :1" -clobs [list $content] } } @@ -94,19 +94,19 @@ @param object_type } { if {[info exists package_ids] && [llength $package_ids]} { - set package_ids_clause " and swi.package_id in ([template::util::tcl_to_sql_list $package_ids]) " + set package_ids_clause " and swi.package_id in ([template::util::tcl_to_sql_list $package_ids]) " } else { - set package_ids_clause "" + set package_ids_clause "" } if {[info exists object_type] && $object_type eq "forums"} { - set object_type_clause " and o.object_type in ('forums_forum', 'forums_message') " + set object_type_clause " and o.object_type in ('forums_forum', 'forums_message') " } elseif {[info exists object_type] && $object_type ne "all" } { - set object_type_clause " and o.object_type = :object_type " + set object_type_clause " and o.object_type = :object_type " } else { - set object_type_clause "" + set object_type_clause "" } - + set weighted_score "score(10) - case when object_type='faq' then nvl(months_between(sysdate,relevant_date)/4,20) when object_type='forums' @@ -144,33 +144,33 @@ set member_clause {} } - set results_ids [db_list search "select s.object_id from + set results_ids [db_list search "select s.object_id from (select rownum as r,o.object_id - from site_wide_index swi, acs_objects o - where swi.object_id= o.object_id + from site_wide_index swi, acs_objects o + where swi.object_id= o.object_id $object_type_clause - and contains (swi.indexed_content,:query, 10)> 0 + and contains (swi.indexed_content,:query, 10)> 0 and ( - $people_search_clause + $people_search_clause (exists (select 1 from acs_object_party_privilege_map m where m.object_id = o.object_id and m.party_id = :user_id - and m.privilege = 'read') + and m.privilege = 'read') $community_id_clause)) $package_ids_clause order by $weighted_score desc) s where r > $offset and r <= $offset + $limit"] # TODO implement stopwords reporting for user query - set count [db_string count "select count(swi.object_id) from site_wide_index swi, acs_objects o where o.object_id=swi.object_id $object_type_clause and contains (swi.indexed_content,:query)> 0 + set count [db_string count "select count(swi.object_id) from site_wide_index swi, acs_objects o where o.object_id=swi.object_id $object_type_clause and contains (swi.indexed_content,:query)> 0 and ( - $people_search_clause + $people_search_clause (exists (select 1 from acs_object_party_privilege_map m where m.object_id = o.object_id and m.party_id = :user_id - and m.privilege = 'read') + and m.privilege = 'read') $member_clause)) $package_ids_clause "] set stop_words "" @@ -206,7 +206,13 @@ @author Dave Bauer (dave@thedesignexperience.org) @creation-date 2005-05-29 - + } { return [list package_key intermedia-driver version 1 automatic_and_queries_p 1 stopwords_p 1] } + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: 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 -N -r1.53 -r1.54 --- openacs-4/packages/search/tcl/search-procs.tcl 29 Jan 2019 19:00:09 -0000 1.53 +++ openacs-4/packages/search/tcl/search-procs.tcl 29 Jan 2019 19:06:26 -0000 1.54 @@ -94,8 +94,8 @@ ad_proc -private search::indexer {} { - Search indexer loops over the existing entries in the search_observer_queue - table and calls the appropriate driver functions to index, update, or + Search indexer loops over the existing entries in the search_observer_queue + table and calls the appropriate driver functions to index, update, or delete the entry. @author Neophytos Demetriou @@ -135,7 +135,7 @@ set object_type [acs_object_type $object_id] ns_log debug "\n-----DB-----\n SEARCH INDEX object type = '${object_type}' \n------------\n " if {[callback::impl_exists -callback search::datasource -impl $object_type] - || [acs_sc_binding_exists_p FtsContentProvider $object_type]} { + || [acs_sc_binding_exists_p FtsContentProvider $object_type]} { array set datasource {mime {} storage_type {} keywords {}} if {[catch { @@ -145,11 +145,11 @@ #ns_log notice "\n-----DB-----\n SEARCH INDEX callback datasource exists for object_type '${object_type}'\n------------\n " array set datasource [lindex [callback -impl $object_type search::datasource -object_id $object_id] 0] } else { - #ns_log notice "invoke contract [list acs_sc::invoke -contract FtsContentProvider -operation datasource -call_args [list $object_id] -impl $object_type]" + #ns_log notice "invoke contract [list acs_sc::invoke -contract FtsContentProvider -operation datasource -call_args [list $object_id] -impl $object_type]" array set datasource [acs_sc::invoke -contract FtsContentProvider \ - -operation datasource \ - -call_args [list $object_id] \ - -impl $object_type] + -operation datasource \ + -call_args [list $object_id] \ + -impl $object_type] } search::content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) $object_id @@ -159,27 +159,27 @@ set datasource(package_id) "" } # set datasource(community_id) [search::dotlrn::get_community_id -package_id $datasource(package_id)] - + if {![info exists datasource(relevant_date)]} { set datasource(relevant_date) "" } - #ns_log notice "callback invoke search::index" + #ns_log notice "callback invoke search::index" callback -impl $driver search::index \ - -object_id $object_id \ - -content $txt \ - -title $datasource(title) \ - -keywords $datasource(keywords) \ - -package_id $datasource(package_id) \ - -community_id $datasource(community_id) \ - -relevant_date $datasource(relevant_date) \ - -datasource datasource + -object_id $object_id \ + -content $txt \ + -title $datasource(title) \ + -keywords $datasource(keywords) \ + -package_id $datasource(package_id) \ + -community_id $datasource(community_id) \ + -relevant_date $datasource(relevant_date) \ + -datasource datasource } else { - #ns_log notice "acs_sc::invoke FtsEngineDriver" + #ns_log notice "acs_sc::invoke FtsEngineDriver" set r [acs_sc::invoke \ - -contract FtsEngineDriver \ - -operation [ad_decode $event UPDATE update_index index] \ - -call_args [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] \ - -impl $driver] + -contract FtsEngineDriver \ + -operation [ad_decode $event UPDATE update_index index] \ + -call_args [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] \ + -impl $driver] } } errMsg]} { ns_log Error "search::indexer: error getting datasource for $object_id $object_type: $errMsg\n[ad_print_stack_trace]\n" @@ -259,13 +259,13 @@ } file { set data [cr_fs_path][db_string get_filename "select content from cr_revisions where revision_id=:object_id"] - set passing_style file + set passing_style file } lob { set data [db_blob_get get_lob_data {}] } } - + search::content_filter -passing_style $passing_style txt data $mime } @@ -281,32 +281,32 @@ upvar $_data data #ns_log notice "---search::content_filter $mime data=[string length $data] <$passing_style>" - + if {$passing_style eq "string"} { - if {[string match text/* $mime]} { - if {$mime eq "text/html"} { - set txt [ns_striphtml $data] - } else { - set txt $data - } - return - } - # - # Write content to a file and let the filter below extract the - # words for the index from the file. - # - set tmp_filename [ad_tmpnam] - set f [open $tmp_filename w] - puts $f $data - close $f - set data $tmp_filename - } + if {[string match text/* $mime]} { + if {$mime eq "text/html"} { + set txt [ns_striphtml $data] + } else { + set txt $data + } + return + } + # + # Write content to a file and let the filter below extract the + # words for the index from the file. + # + set tmp_filename [ad_tmpnam] + set f [open $tmp_filename w] + puts $f $data + close $f + set data $tmp_filename + } set txt [search::convert::binary_to_text -filename $data -mime_type $mime] #ns_log notice "search::content_filter txt len [string length $txt]" if {[info exists tmp_filename]} { - file delete -- $tmp_filename + file delete -- $tmp_filename } } @@ -356,30 +356,30 @@ } - ad_proc -callback search::index { - -object_id + -object_id -content -title -keywords -community_id -relevant_date {-description ""} {-datasource ""} - {-package_id ""} + {-package_id ""} } { This callback is invoked from the search::indexer scheduled procedure to add an item to the index } - -ad_proc -callback search::update_index { - -object_id +ad_proc -callback search::update_index { + -object_id -content -title -keywords -community_id -relevant_date {-description ""} {-datasource ""} - {-package_id ""} + {-package_id ""} } { This callback is invoked from the search::indexer scheduled procedure to update an item already in the index @@ -390,7 +390,7 @@ -text } { This callback is invoked to return an HTML fragment highlighting the terms in query -} - +} - ad_proc -callback search::driver_info { } { @@ -412,17 +412,17 @@ -package_id } { if dotlrn is installed find the package's community_id - + @param package_id Package to find community @return dotLRN community_id. empty string if package_id is not under a dotlrn package instance } { if {[apm_package_installed_p dotlrn]} { - set site_node [site_node::get_node_id_from_object_id -object_id $package_id] - set dotlrn_package_id [site_node::closest_ancestor_package -node_id $site_node -package_key dotlrn -include_self] - set community_id [db_string get_community_id {select community_id from dotlrn_communities_all where package_id=:dotlrn_package_id} -default [db_null]] - return $community_id - } + set site_node [site_node::get_node_id_from_object_id -object_id $package_id] + set dotlrn_package_id [site_node::closest_ancestor_package -node_id $site_node -package_key dotlrn -include_self] + set community_id [db_string get_community_id {select community_id from dotlrn_communities_all where package_id=:dotlrn_package_id} -default [db_null]] + return $community_id + } return "" } @@ -437,7 +437,7 @@ @param value value of the argument @param object_table_alias SQL alias of table that contains the object_id to join against - + @return list in array format of {from_clause {} where_clause {}} } - @@ -447,7 +447,7 @@ } { set names [list] foreach procname [info procs ::callback::search::extra_arg::impl::*] { - lappend names [namespace tail $procname] + lappend names [namespace tail $procname] } return $names } @@ -484,8 +484,6 @@ return $extra_args } - - # Local variables: # mode: tcl # tcl-indent-level: 4