set object_type_clause " and o.object_type = :object_type "
}else{
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'
then nvl(months_between(sysdate,relevant_date)*1.5,20)
when object_type='phb_person'
then 0
when object_type='news'
then nvl(months_between(sysdate,relevant_date)*2,20)
when object_type='cal_item'
then nvl(months_between(sysdate,relevant_date)*2,20)
when object_type='file_storage_object'
then nvl(months_between(sysdate,relevant_date)*1.5,20)
when object_type='survey'
then nvl(months_between(sysdate,relevant_date)*1.5,20)
when object_type='static_portal_content'
then nvl(months_between(sysdate,relevant_date)*1.5,20)
end"
set people_search_clause { o.object_type = 'phb_person' or }
if [apm_package_installed_p "dotlrn"]{
set is_guest_p [search::is_guest_p]
if {$is_guest_p}{
set people_search_clause { and }; # doesn't look like legal SQL
}
set is_member {
exists ( select 1
from dotlrn_member_rels_approved
where community_id = swi.community_id
and user_id = :user_id)}
set community_id_clause " and (swi.community_id is null or $is_member) "
set member_clause " and $is_member "
}else{
set community_id_clause {}
set member_clause {}
}
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
$object_type_clause
and contains (swi.indexed_content,:query, 10)> 0
and (
$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')
$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