Index: openacs-4/packages/search/search.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/search.info,v diff -u -N -r1.22 -r1.23 --- openacs-4/packages/search/search.info 10 Mar 2005 01:42:14 -0000 1.22 +++ openacs-4/packages/search/search.info 8 Nov 2005 18:24:06 -0000 1.23 @@ -30,6 +30,7 @@ + Index: openacs-4/packages/search/catalog/search.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/catalog/search.en_US.ISO-8859-1.xml,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/search/catalog/search.en_US.ISO-8859-1.xml 8 Jun 2005 16:36:06 -0000 1.7 +++ openacs-4/packages/search/catalog/search.en_US.ISO-8859-1.xml 8 Nov 2005 18:24:06 -0000 1.8 @@ -1,35 +1,40 @@ - + + . + Search took Advanced Search - The "<b>AND</b>" operator is unnecessary -- we include all search terms by default. + "advanced search" anytime Date Range details - Display Feeling Lucky "<b>%stopwords%</b>" is a very common word and was not included in your search. FtsEngineDriver not available! Make sure all words are spelled correctly. - No pages were found containing "<b>%query%</b>". - The following words are very common and were not included in your search: <strong>%stopwords;noquote%</strong>. + No pages were found containing " + The following words are very common and were not included in your search: + Tip: In most browsers you can just hit the return key instead of clicking on the search button. Try different keywords. Try more general keywords. Try your query on: %stw;noquote% - You must specify some keywords. + You must specify some keywords + &nbsp;Display Next - Search is not currently configured. Please contact the webmaster to enable it. + of about past 3 months past 6 months past year Previous Result page: + Results results - Results <b>%low% - %high%</b> of about <b>%count%</b>. Search took %elapsed% seconds. Search - Searched for: <b>%query%</b> + Searched for: %query% + seconds. + selected Suggestions: - Tip: In most browsers you can just hit the return key instead of clicking on the search button. + "<b>AND</b>" operator is unnecessary -- we include all search terms by default. Try fewer keywords. Untitled Index: openacs-4/packages/search/sql/oracle/load-site-wide-search =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/Attic/load-site-wide-search,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/sql/oracle/load-site-wide-search 21 May 2005 11:34:10 -0000 1.1 +++ openacs-4/packages/search/sql/oracle/load-site-wide-search 8 Nov 2005 18:24:06 -0000 1.2 @@ -39,10 +39,14 @@ # For programming convenience just drop everything sqlplus ${USERNAME}/${PASSWORD} @search-tables-drop.sql sqlplus ${USERNAME}/${PASSWORD} @search-packages-drop.sql +sqlplus ${USERNAME}/${PASSWORD} @search-sc-drop.sql sqlplus ${USERNAME}/${PASSWORD} @search-index-drop.sql ${USERNAME} ${PASSWORD} sqlplus ${USERNAME}/${PASSWORD} @search-tables-create.sql sqlplus ${USERNAME}/${PASSWORD} @search-packages-create.sql -sqlplus ctxsys/${CTXSYS_PASSWORD} @search-ctxsys.sql ${USERNAME} ${PASSWORD} +sqlplus ${USERNAME}/${PASSWORD} @search-sc-create.sql +sqlplus ${USERNAME}/${PASSWORD} @syndication-create.sql + +sqlplus ctxsys/${CTXSYS_PASSWORD} @search-ctxsys.sql ${USERNAME} ${PASSWORD} sqlplus ${USERNAME}/${PASSWORD} @search-index-create.sql ${USERNAME} ${PASSWORD} sqlplus ${USERNAME}/${PASSWORD} @search-from-scratch.sql 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 -N -r1.2 -r1.3 --- openacs-4/packages/search/sql/oracle/search-create.sql 26 Jul 2004 13:04:56 -0000 1.2 +++ openacs-4/packages/search/sql/oracle/search-create.sql 8 Nov 2005 18:24:06 -0000 1.3 @@ -1,4 +1,3 @@ @@ search-tables-create.sql @@ search-packages-create.sql @@ search-sc-create.sql -@@ syndication-create.sql Index: openacs-4/packages/search/sql/oracle/search-from-scratch.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/search-from-scratch.sql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/sql/oracle/search-from-scratch.sql 21 May 2005 11:34:10 -0000 1.1 +++ openacs-4/packages/search/sql/oracle/search-from-scratch.sql 8 Nov 2005 18:24:06 -0000 1.2 @@ -22,28 +22,41 @@ -- @creation-date 13-May-2005 -- -truncate table site_wide_index; +truncate table search_observer_queue; -insert into site_wide_index (object_id, object_name, datastore) - select message_id, subject, 'a' from forums_messages; +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('cal_item') ; +commit; + +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects, cr_items where object_id=live_revision and object_type in ('file_storage_object') ; +commit; -insert into site_wide_index (object_id, object_name, datastore) - select event_id, name, 'a' from acs_events; +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('static_portal_content'); +commit; -insert into site_wide_index (object_id, object_name, datastore) - select entry_id, question, 'a' from faq_q_and_as; +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('forums_message') ; +commit; -insert into site_wide_index (object_id, object_name, datastore) - select content_id, pretty_name, 'a' from static_portal_content; +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('forums_forum') ; +commit; -insert into site_wide_index (object_id, object_name, datastore) - select survey_id, name, 'a' from surveys; +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects, cr_items, cr_news where news_id=live_revision and object_id=live_revision and object_type in ('news'); +-- and archive_date is null; +commit; +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('faq') ; commit; -alter index sws_ctx_index rebuild parameters ('sync') ; +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('survey'); +commit; -exit +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects,cr_items where object_type in ('phb_person') and object_id=live_revision ; +commit; +--alter index swi_index rebuild parameters ('sync') ; + +exit; + + + Index: openacs-4/packages/search/sql/oracle/search-index-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/Attic/search-index-create.sql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/sql/oracle/search-index-create.sql 21 May 2005 11:34:10 -0000 1.1 +++ openacs-4/packages/search/sql/oracle/search-index-create.sql 8 Nov 2005 18:24:06 -0000 1.2 @@ -28,16 +28,25 @@ ctx_ddl.create_section_group('swsgroup', 'basic_section_group'); ctx_ddl.add_field_section('swsgroup', 'oneline', 'oneline', TRUE); end; -/ +/ create index swi_index on site_wide_index (indexed_content) +indextype is ctxsys.context parameters ('datastore ctxsys.default_datastore memory 250M'); + -- create intermedia index for site wide index begin ctx_ddl.create_preference('sws_user_datastore', 'user_datastore'); ctx_ddl.set_attribute('sws_user_datastore', 'procedure', 'sws_user_proc_&1'); end; / -create index sws_ctx_index on site_wide_index (datastore) -indextype is ctxsys.context parameters ('datastore sws_user_datastore memory 250M section group swsgroup'); +--create index swi_ctx_index on site_wide_index (datastore) +--indextype is ctxsys.context parameters ('datastore sws_user_datastore memory 250M section group swsgroup'); + +--create index swi_ctx_index on site_wide_index (datastore) +--indextype is ctxsys.context parameters ('datastore ctxsys.default_datastore memory 250M'); + +create index swi_index on site_wide_index (indexed_content) +indextype is ctxsys.context parameters ('datastore ctxsys.default_datastore memory 250M'); + exit; \ No newline at end of file Index: openacs-4/packages/search/sql/oracle/search-index-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/Attic/search-index-drop.sql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/sql/oracle/search-index-drop.sql 21 May 2005 11:34:10 -0000 1.1 +++ openacs-4/packages/search/sql/oracle/search-index-drop.sql 8 Nov 2005 18:24:06 -0000 1.2 @@ -27,6 +27,6 @@ end; / -drop index sws_ctx_index; +drop index swi_ctx_index; exit; 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 -N -r1.2 -r1.3 --- openacs-4/packages/search/sql/oracle/search-packages-create.sql 21 May 2005 11:34:10 -0000 1.2 +++ openacs-4/packages/search/sql/oracle/search-packages-create.sql 8 Nov 2005 18:24:06 -0000 1.3 @@ -26,19 +26,215 @@ -- The site_wide_search packages holds generally useful -- PL/SQL procedures and functions. +create or replace package search_observer +as + procedure enqueue ( + object_id acs_objects.object_id%TYPE, + event search_observer_queue.event%TYPE +); + procedure dequeue ( + object_id acs_objects.object_id%TYPE, event + search_observer_queue.event%TYPE, event_date + search_observer_queue.event_date%TYPE +); +end search_observer; +/ +show errors + +create or replace package body search_observer +as + procedure enqueue ( + object_id acs_objects.object_id%TYPE, + event 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 acs_objects.object_id%TYPE, + event search_observer_queue.event%TYPE, + event_date search_observer_queue.event_date%TYPE +) is + begin + + + delete from search_observer_queue + where object_id = dequeue.object_id + and event = dequeue.event + and to_char(dequeue.event_date,'yyyy-mm-dd hh24:mi:ss') = to_char(dequeue.event_date,'yyyy-mm-dd hh24:mi:ss'); + + end dequeue; +end search_observer; +/ +show errors + + create or replace package site_wide_search as + procedure register_event (p_object_id search_observer_queue.object_id%TYPE, + p_event search_observer_queue.event%TYPE); + procedure logger (p_logmessage varchar); + + function im_convert( + query in varchar2 default null + ) return varchar2; + end site_wide_search; / show errors create or replace package body site_wide_search as + procedure register_event (p_object_id search_observer_queue.object_id%TYPE, + p_event search_observer_queue.event%TYPE) is + begin + insert into search_observer_queue + (object_id, event) + values + (p_object_id, p_event); + end register_event; + procedure logger (p_logmessage varchar) is begin insert into sws_log_messages (logmessage) values (p_logmessage); end logger; + + -- Query to take free text user entered query and frob it into something + -- that will make interMedia happy. Provided by Oracle. + function im_convert( + query in varchar2 default null + ) return varchar2 + is + i number :=0; + len number :=0; + char varchar2(1); + minusString varchar2(256); + plusString varchar2(256); + mainString varchar2(256); + mainAboutString varchar2(500); + finalString varchar2(500); + hasMain number :=0; + hasPlus number :=0; + hasMinus number :=0; + token varchar2(256); + tokenStart number :=1; + tokenFinish number :=0; + inPhrase number :=0; + inPlus number :=0; + inWord number :=0; + inMinus number :=0; + completePhrase number :=0; + completeWord number :=0; + code number :=0; + begin + + len := length(query); + + -- we iterate over the string to find special web operators + for i in 1..len loop + char := substr(query,i,1); + if(char = '"') then + if(inPhrase = 0) then + inPhrase := 1; + tokenStart := i; + else + inPhrase := 0; + completePhrase := 1; + tokenFinish := i-1; + end if; + elsif(char = ' ') then + if(inPhrase = 0) then + completeWord := 1; + tokenFinish := i-1; + end if; + elsif(char = '+') then + inPlus := 1; + tokenStart := i+1; + elsif((char = '-') and (i = tokenStart)) then + inMinus :=1; + tokenStart := i+1; + end if; + + if(completeWord=1) then + token := '{ '||substr(query,tokenStart,tokenFinish-tokenStart+1)||' }'; + if(inPlus=1) then + plusString := plusString||','||token||'*10'; + hasPlus :=1; + elsif(inMinus=1) then + minusString := minusString||'OR '||token||' '; + hasMinus :=1; + else + mainString := mainString||' NEAR '||token; + mainAboutString := mainAboutString||' '||token; + hasMain :=1; + end if; + tokenStart :=i+1; + tokenFinish :=0; + inPlus := 0; + inMinus :=0; + end if; + completePhrase := 0; + completeWord :=0; + end loop; + + -- find the last token + token := '{ '||substr(query,tokenStart,len-tokenStart+1)||' }'; + if(inPlus=1) then + plusString := plusString||','||token||'*10'; + hasPlus :=1; + elsif(inMinus=1) then + minusString := minusString||'OR '||token||' '; + hasMinus :=1; + else + mainString := mainString||' NEAR '||token; + mainAboutString := mainAboutString||' '||token; + hasMain :=1; + end if; + + + mainString := substr(mainString,6,length(mainString)-5); + mainAboutString := replace(mainAboutString,'{',' '); + mainAboutString := replace(mainAboutString,'}',' '); + mainAboutString := replace(mainAboutString,')',' '); + mainAboutString := replace(mainAboutString,'(',' '); + plusString := substr(plusString,2,length(plusString)-1); + minusString := substr(minusString,4,length(minusString)-4); + + -- we find the components present and then process them based on the specific combinations + code := hasMain*4+hasPlus*2+hasMinus; + if(code = 7) then + finalString := '('||plusString||','||mainString||'*2.0,about('||mainAboutString||')*0.5) NOT ('||minusString||')'; + elsif (code = 6) then + finalString := plusString||','||mainString||'*2.0'||',about('||mainAboutString||')*0.5'; + elsif (code = 5) then + finalString := '('||mainString||',about('||mainAboutString||')) NOT ('||minusString||')'; + elsif (code = 4) then + finalString := mainString; + finalString := replace(finalString,'*1,',NULL); + finalString := '('||finalString||')*2.0,about('||mainAboutString||')'; + elsif (code = 3) then + finalString := '('||plusString||') NOT ('||minusString||')'; + elsif (code = 2) then + finalString := plusString; + elsif (code = 1) then + -- not is a binary operator for intermedia text + finalString := 'totallyImpossibleString'||' NOT ('||minusString||')'; + elsif (code = 0) then + finalString := ''; + end if; + + return finalString; + end; + end site_wide_search; / show errors @@ -49,251 +245,126 @@ create or replace trigger forums_messages_sws_insert_tr after insert on forums_messages for each row begin - insert into site_wide_index (object_id, object_name, datastore) - values (:new.message_id, :new.subject, 'a'); + site_wide_search.register_event (:new.message_id, 'INSERT'); end; / show errors create or replace trigger forums_messages_sws_update_tr after update on forums_messages for each row begin - update site_wide_index - set object_name=:new.subject, - datastore='a' - where object_id = :new.message_id; + site_wide_search.register_event (:new.message_id, 'UPDATE'); end; / show errors create or replace trigger forums_messages_sws_delete_tr after delete on forums_messages for each row begin - delete from site_wide_index - where object_id = :old.message_id; + site_wide_search.register_event (:new.message_id, 'DELETE'); end; / show errors -create or replace procedure forums_messages_sws_helper (p_tlob in out nocopy clob, p_object_id in varchar) -is - cursor forums_messages_cursor(v_object_id char) is - select subject, content, p.first_names || ' ' || p.last_name as - author_name, parties.email - from forums_messages fm, persons p, parties - where p.person_id = fm.user_id - and parties.party_id = p.person_id - and fm.message_id = v_object_id; -begin - for forums_messages_record in forums_messages_cursor(p_object_id) loop - dbms_lob.writeappend(p_tlob, length(''), ''); - if forums_messages_record.subject is not null then - dbms_lob.writeappend(p_tlob, length(forums_messages_record.subject) + 1, forums_messages_record.subject || ' '); - end if; - dbms_lob.writeappend(p_tlob, length(''), ''); - dbms_lob.writeappend(p_tlob, length(forums_messages_record.author_name) + 1, forums_messages_record.author_name || ' '); - if forums_messages_record.content is not null then - dbms_lob.append(p_tlob, forums_messages_record.content); - end if; - end loop; -end; -/ -show errors; -------------------------------------------------------- -- static-portal triggers and procedures create or replace trigger static_portal_sws_insert_tr after insert on static_portal_content for each row begin - insert into site_wide_index (object_id, object_name, datastore) - values (:new.content_id, :new.pretty_name, 'a'); + site_wide_search.register_event (:new.content_id, 'INSERT'); end; / show errors create or replace trigger static_portal_sws_update_tr after update on static_portal_content for each row begin - update site_wide_index - set object_name=:new.pretty_name, - datastore='a' - where object_id = :new.content_id; + site_wide_search.register_event (:new.content_id, 'UPDATE'); end; / show errors create or replace trigger static_portal_sws_delete_tr after delete on static_portal_content for each row begin - delete from site_wide_index - where object_id = :old.content_id; + site_wide_search.register_event (:new.content_id, 'DELETE'); end; / show errors -create or replace procedure static_portal_sws_helper (p_tlob in out nocopy clob, p_object_id in varchar) -is - cursor static_portal_content_cursor(v_object_id char) is - select pretty_name, body, p.first_names || ' ' || p.last_name as - author_name, parties.email - from static_portal_content fm, persons p, parties, acs_objects ao - where fm.content_id = ao.object_id - and p.person_id = ao.creation_user - and parties.party_id = p.person_id - and fm.content_id = v_object_id; -begin - for static_portal_content_record in static_portal_content_cursor(p_object_id) loop - dbms_lob.writeappend(p_tlob, length(''), ''); - if static_portal_content_record.pretty_name is not null then - dbms_lob.writeappend(p_tlob, length(static_portal_content_record.pretty_name) + 1, static_portal_content_record.pretty_name || ' '); - end if; - dbms_lob.writeappend(p_tlob, length(''), ''); - dbms_lob.writeappend(p_tlob, length(static_portal_content_record.author_name) + 1, static_portal_content_record.author_name || ' '); - if static_portal_content_record.body is not null then - dbms_lob.append(p_tlob, static_portal_content_record.body); - end if; - end loop; -end; -/ -show errors; - -------------------------------------------------------- -- ACS-events triggers and procedures -- I think only calendar makes use of the acs-events tables. create or replace trigger acs_events_sws_insert_tr after insert on acs_events for each row begin - insert into site_wide_index (object_id, object_name, datastore) - values (:new.event_id, :new.name, 'a'); + site_wide_search.register_event (:new.event_id, 'INSERT'); end; / show errors create or replace trigger acs_events_sws_update_tr after update on acs_events for each row begin - update site_wide_index - set object_name=:new.name, - datastore='a' - where object_id = :new.event_id; + site_wide_search.register_event (:new.event_id, 'UPDATE'); end; / show errors create or replace trigger acs_events_sws_delete_tr after delete on acs_events for each row begin - delete from site_wide_index - where object_id = :old.event_id; + site_wide_search.register_event (:new.event_id, 'DELETE'); end; / show errors -create or replace procedure acs_events_sws_helper (p_tlob in out nocopy clob, p_object_id in varchar) -is - cursor acs_events_cursor(v_object_id char) is - select name, description, p.first_names || ' ' || p.last_name as - author_name, parties.email - from acs_events ae, acs_objects ao, persons p, parties - where p.person_id = ao.creation_user - and ao.object_id = v_object_id - and parties.party_id = p.person_id - and ae.event_id = v_object_id; -begin - for acs_events_record in acs_events_cursor(p_object_id) loop - dbms_lob.writeappend(p_tlob, length(''), ''); - if acs_events_record.name is not null then - dbms_lob.writeappend(p_tlob, length(acs_events_record.name) + 1, acs_events_record.name || ' '); - end if; - dbms_lob.writeappend(p_tlob, length(''), ''); - dbms_lob.writeappend(p_tlob, length(acs_events_record.author_name) + 1, acs_events_record.author_name || ' '); - if acs_events_record.description is not null then - dbms_lob.writeappend(p_tlob, length(acs_events_record.description) + 1, acs_events_record.description || ' '); - end if; - end loop; -end; -/ -show errors; - -------------------------------------------------------- -- FAQ triggers and procedures create or replace trigger faq_q_and_as_sws_insert_tr after insert on faq_q_and_as for each row begin - insert into site_wide_index (object_id, object_name, datastore) - values (:new.entry_id, :new.question, 'a'); + site_wide_search.register_event (:new.entry_id, 'INSERT'); end; / show errors create or replace trigger faq_q_and_as_sws_update_tr after update on faq_q_and_as for each row begin - update site_wide_index - set object_name=:new.question, - datastore='a' - where object_id = :new.entry_id; + site_wide_search.register_event (:new.entry_id, 'UPDATE'); end; / show errors create or replace trigger faq_q_and_as_sws_delete_tr after delete on faq_q_and_as for each row begin - delete from site_wide_index - where object_id = :old.entry_id; + site_wide_search.register_event (:new.entry_id, 'DELETE'); end; / show errors -create or replace procedure faq_q_and_as_sws_helper (p_tlob in out nocopy clob, p_object_id in varchar) -is - cursor faq_q_and_as_cursor(v_object_id char) is - select question, answer, p.first_names || ' ' || p.last_name as - author_name, parties.email - from faq_q_and_as ae, acs_objects ao, persons p, parties - where p.person_id = ao.creation_user - and ao.object_id = v_object_id - and parties.party_id = p.person_id - and ae.entry_id = v_object_id; -begin - for faq_q_and_as_record in faq_q_and_as_cursor(p_object_id) loop - dbms_lob.writeappend(p_tlob, length(''), ''); - if faq_q_and_as_record.question is not null then - dbms_lob.writeappend(p_tlob, length(faq_q_and_as_record.question) + 1, faq_q_and_as_record.question || ' '); - end if; - dbms_lob.writeappend(p_tlob, length(''), ''); - dbms_lob.writeappend(p_tlob, length(faq_q_and_as_record.author_name) + 1, faq_q_and_as_record.author_name || ' '); - if faq_q_and_as_record.answer is not null then - dbms_lob.writeappend(p_tlob, length(faq_q_and_as_record.answer) + 1, faq_q_and_as_record.answer || ' '); - end if; - end loop; -end; -/ -show errors; -------------------------------------------------------- -- Survey Procs create or replace trigger surveys_sws_insert_tr after insert on surveys for each row begin - insert into site_wide_index (object_id, object_name, datastore) - values (:new.survey_id, :new.name, 'a'); + site_wide_search.register_event (:new.survey_id, 'INSERT'); end; / show errors create or replace trigger surveys_sws_update_tr after update on surveys for each row begin - update site_wide_index - set object_name=:new.name, - datastore='a' - where object_id = :new.survey_id; + site_wide_search.register_event (:new.survey_id, 'UPDATE'); end; / show errors @@ -302,135 +373,91 @@ create or replace trigger surveys_sws_delete_tr after delete on surveys for each row begin - delete from site_wide_index - where object_id = :old.survey_id; + site_wide_search.register_event (:new.survey_id, 'DELETE'); end; / show errors -create or replace procedure surveys_sws_helper (p_tlob in out nocopy clob, p_object_id in varchar) -is +-------------------------------------------------------- +-- Photobook Procs - cursor surveys_cursor(v_object_id char) is - select name, description, p.first_names || ' ' || p.last_name as - author_name, parties.email - from surveys sv, persons p, parties, acs_objects ao - where sv.survey_id = ao.object_id - and p.person_id = ao.creation_user - and parties.party_id = p.person_id - and sv.survey_id = v_object_id; +create or replace trigger phb_person_sws_insert_tr + after insert on phb_person for each row +begin + site_wide_search.register_event (:new.person_id, 'INSERT'); +end; +/ +show errors - cursor survey_sections_cursor(v_survey_id char) is - select section_id, name, description - from survey_sections sv - where sv.survey_id = v_survey_id; - - cursor survey_questions_cursor(v_section_id char) is - select question_text - from survey_questions - where section_id = v_section_id; - +create or replace trigger phb_person_sws_update_tr + after update on phb_person for each row begin - for surveys_record in surveys_cursor(p_object_id) loop - dbms_lob.writeappend(p_tlob, length(''), ''); - if surveys_record.name is not null then - dbms_lob.writeappend(p_tlob, length(surveys_record.name) + 1, surveys_record.name || ' '); - end if; - dbms_lob.writeappend(p_tlob, length(''), ''); - dbms_lob.writeappend(p_tlob, length(surveys_record.author_name) + 1, surveys_record.author_name || ' '); - if surveys_record.description is not null then - dbms_lob.writeappend(p_tlob, length(surveys_record.description) + 1, surveys_record.description || ' '); - end if; + site_wide_search.register_event (:new.person_id, 'UPDATE'); +end; +/ +show errors - for survey_sections_record in survey_sections_cursor(p_object_id) loop - dbms_lob.writeappend(p_tlob, length(''), ''); - if survey_sections_record.name is not null then - dbms_lob.writeappend(p_tlob, length(survey_sections_record.name) + 1, survey_sections_record.name || ' '); - end if; - dbms_lob.writeappend(p_tlob, length(''), ''); - if survey_sections_record.description is not null then - dbms_lob.append(p_tlob, survey_sections_record.description); - end if; - - for survey_questions_record in survey_questions_cursor(survey_sections_record.section_id) loop - dbms_lob.writeappend(p_tlob, length(''), ''); - if survey_questions_record.question_text is not null then - dbms_lob.append(p_tlob, survey_questions_record.question_text); - end if; - dbms_lob.writeappend(p_tlob, length(''), ''); - end loop; - - end loop; - - end loop; + +create or replace trigger phb_person_sws_delete_tr + after delete on phb_person for each row +begin + site_wide_search.register_event (:new.person_id, 'DELETE'); end; / -show errors; +show errors -create or replace trigger survey_sections_sws_insert_tr - after insert on survey_sections for each row +-------------------------------------------------------- +-- FAQ Procs + +create or replace trigger faq_q_and_as_sws_insert_tr + after insert on faq_q_and_as for each row begin - update site_wide_index - set datastore='a' - where object_id = :new.survey_id; + site_wide_search.register_event (:new.faq_id, 'INSERT'); end; / show errors -create or replace trigger survey_sections_sws_update_tr - after update on survey_sections for each row +create or replace trigger faq_q_and_as_sws_update_tr + after update on faq_q_and_as for each row begin - update site_wide_index - set datastore='a' - where object_id = :new.survey_id; + site_wide_search.register_event (:new.faq_id, 'UPDATE'); end; / show errors -create or replace trigger survey_sections_sws_delete_tr - after delete on survey_sections for each row +create or replace trigger faq_q_and_as_sws_delete_tr + after delete on faq_q_and_as for each row begin - update site_wide_index - set datastore='a' - where object_id = :old.survey_id; + site_wide_search.register_event (:new.faq_id, 'DELETE'); end; / show errors -create or replace trigger survey_questions_sws_insert_tr - after insert on survey_questions for each row +-------------------------------------------------------- +-- Survey Procs + +create or replace trigger surveys_sws_insert_tr + after insert on surveys for each row begin - update site_wide_index - set datastore='a' - where object_id in (select survey_id - from survey_sections - where section_id = :new.section_id); + site_wide_search.register_event (:new.survey_id, 'INSERT'); end; / show errors -create or replace trigger survey_questions_sws_update_tr - after update on survey_questions for each row +create or replace trigger surveys_sws_update_tr + after update on surveys for each row begin - update site_wide_index - set datastore='a' - where object_id in (select survey_id - from survey_sections - where section_id = :new.section_id); + site_wide_search.register_event (:new.survey_id, 'UPDATE'); end; / show errors -create or replace trigger survey_questions_sws_delete_tr - after delete on survey_questions for each row +create or replace trigger surveys_sws_delete_tr + after delete on surveys for each row begin - update site_wide_index - set datastore='a' - where object_id in (select survey_id - from survey_sections - where section_id = :old.section_id); + site_wide_search.register_event (:new.survey_id, 'DELETE'); end; / show errors @@ -441,51 +468,20 @@ create or replace procedure sws_user_datastore_proc ( p_rid in rowid, p_tlob in out nocopy clob ) is v_object_id site_wide_index.object_id%type; - v_object_type acs_objects.object_type%type; begin site_wide_search.logger ('entered sws_user_datastore_proc'); - select swi.object_id, ao.object_type - into v_object_id, v_object_type + + select indexed_content + into p_tlob from site_wide_index swi, acs_objects ao - where swi.object_id = ao.object_id - and p_rid = swi.rowid; - - -- clean out the clob we're going to stuff - dbms_lob.trim(p_tlob, 0); + where swi.object_id = ao.object_id + and p_rid = swi.rowid; - site_wide_search.logger ('in sws_user_datastore_proc with type ' || v_object_type); - -- handle different sections - if v_object_type = 'forums_message' then - site_wide_search.logger ('calling forums_messages_sws_helper '); - forums_messages_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'cal_item' then - site_wide_search.logger ('calling acs_events_sws_helper with cal_item'); - acs_events_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'faq_q_and_a' then - site_wide_search.logger ('calling faq_q_and_as_sws_helper with faq_q_and_a'); - faq_q_and_as_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'static_portal_content' then - site_wide_search.logger ('calling static_portal_sws_helper'); - static_portal_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'survey' then - site_wide_search.logger ('calling surveys_sws_helper'); - surveys_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'survey_section' then - site_wide_search.logger ('calling survey_sections_sws_helper'); - survey_sections_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'survey_question' then - site_wide_search.logger ('calling survey_questions_sws_helper'); - survey_questions_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'survey_response' then - site_wide_search.logger ('calling survey_responses_sws_helper'); - survey_responses_sws_helper(p_tlob, v_object_id); - elsif v_object_type = 'wp_slides' then - v_object_type := 'foobar'; - end if; + site_wide_search.logger ('in sws_user_datastore_proc with type ' || v_object_id); + end; / show errors; exit; - 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 -N -r1.2 -r1.3 --- openacs-4/packages/search/sql/oracle/search-packages-drop.sql 21 May 2005 11:34:10 -0000 1.2 +++ openacs-4/packages/search/sql/oracle/search-packages-drop.sql 8 Nov 2005 18:24:06 -0000 1.3 @@ -1,24 +1,2 @@ --- --- Copyright (C) 2005 MIT --- --- This file is part of dotLRN. --- --- dotLRN is free software; you can redistribute it and/or modify it under the --- terms of the GNU General Public License as published by the Free Software --- Foundation; either version 2 of the License, or (at your option) any later --- version. --- --- dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY --- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more --- details. --- - --- --- Drop database packages for .LRN site-wide search --- --- @author Dirk Gomez --- @version $Id$ --- @creation-date 13-May-2005 - -exit; \ No newline at end of file +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 -N -r1.1 -r1.2 --- openacs-4/packages/search/sql/oracle/search-sc-create.sql 2 Jul 2002 01:52:38 -0000 1.1 +++ openacs-4/packages/search/sql/oracle/search-sc-create.sql 8 Nov 2005 18:24:06 -0000 1.2 @@ -183,3 +183,5 @@ end; / show errors + +exit; \ No newline at end of file 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 -N -r1.4 -r1.5 --- openacs-4/packages/search/sql/oracle/search-tables-create.sql 7 Jun 2005 19:58:15 -0000 1.4 +++ openacs-4/packages/search/sql/oracle/search-tables-create.sql 8 Nov 2005 18:24:06 -0000 1.5 @@ -30,21 +30,39 @@ constraint sws_index_fk references acs_objects(object_id) on delete cascade, object_name varchar(4000), indexed_content clob, - package_id integer --- TODO Dirk: bring back not null constraint --- constraint swi_package_id_nn --- not null - constraint swi_package_id_fk - references apm_packages - on delete cascade, - datastore char(1) not null, - event_date date - default sysdate, - event varchar(6) - constraint site_wide_index_event_ck - check (event in ('INSERT','DELETE','UPDATE')) + -- Dirk Gomez: no not null constraint because we also want to + -- be able to index objects which are not tied to an object, + -- in particular people. + package_id integer + constraint swi_package_id_fk + references apm_packages + on delete cascade, + -- Dirk Gomez: This is a .LRNism. It looks like .LRN has not + -- only object-granular permiissions, but also + -- community-granular ones. In search we need not only check + -- whether a user has the right to view this object, but also + -- its community. In pure OpenACS this should always be a + -- null column and it should have no referential integrity. + community_id integer + constraint swi_community_id_fk + references dotlrn_communities_all + on delete cascade, + -- Dirk Gomez: That's the place to put an object's relevant + -- date which is part of the ranking function. In calendar + -- this is the item date, in forum it could be the last reply + -- date to a thread etc. + relevant_date date ); +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')) +); + -- Intermedia sometimes is painful to debug, so I added a logging -- mechanism which relies on Oracle's autonomous transactions: DML -- statements are committed immediately so you can access this data 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 -N -r1.2 -r1.3 --- openacs-4/packages/search/sql/oracle/search-tables-drop.sql 21 May 2005 11:34:10 -0000 1.2 +++ openacs-4/packages/search/sql/oracle/search-tables-drop.sql 8 Nov 2005 18:24:07 -0000 1.3 @@ -1,7 +1 @@ -drop table site_wide_index; drop table search_observer_queue; -drop table sws_log_messages; - -exit; - - Index: openacs-4/packages/search/sql/oracle/syndication-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/syndication-create.sql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/sql/oracle/syndication-create.sql 26 Jul 2004 13:04:56 -0000 1.1 +++ openacs-4/packages/search/sql/oracle/syndication-create.sql 8 Nov 2005 18:24:07 -0000 1.2 @@ -13,3 +13,5 @@ comment on table syndication is 'stores xml fragments for consolidating into rss feeds. Also stores an html version of the content item and it''s url from the link field of the rss'; + +exit; Index: openacs-4/packages/search/sql/oracle/syndication-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/oracle/syndication-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/sql/oracle/syndication-drop.sql 8 Nov 2005 18:24:07 -0000 1.1 @@ -0,0 +1,3 @@ +drop table syndication; + +exit; Index: openacs-4/packages/search/tcl/search-convert-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-convert-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/tcl/search-convert-procs.tcl 8 Nov 2005 18:24:07 -0000 1.1 @@ -0,0 +1,66 @@ +ad_library { + Binaries conversion procedures for the search package. + Thanks to Carsten Clasohm for suggesting the converter programs. + + @author Dirk Gomez + @creation-date 2005-06-25 + @cvs-id $Id: search-convert-procs.tcl,v 1.1 2005/11/08 18:24:07 dirkg Exp $ +} + + +namespace eval search {} +namespace eval search::convert {} + +ad_proc -public search::convert::binary_to_text { + {-filename:required} + {-mime_type:required} +} { + Converts the binary file to text and returns this as a string. + (Carsten Clasohm provided the converters.) + + @author Dirk Gomez + @creation-date 2005-06-25 +} { + + set tmp_filename [ns_tmpnam] + set result "" + + switch $mime_type { + {application/msword} - + {application/vnd.ms-word} { + set convert_command {/usr/local/bin/catdoc $filename >$tmp_filename} + } + {application/powerpoint} { + set convert_command {strings $filename >$tmp_filename} + } + {application/msexcel} { + set convert_command {/usr/local/bin/xls2csv $filename >$tmp_filename} + } + {application/pdf} { + set convert_command {/usr/local/bin/pdftotext $filename $tmp_filename} + } + {text/html} { + return [catch {[ns_striphtml $filename]} error] + } + default { + # If there's nothing implemented for a particular mime type + # we'll just index filename and pathname + return "" + } + } + + if {[catch {eval exec $convert_command} err]} { + catch {file delete $tmp_filename} + puts "DIRK conversion failed - $convert_command: $err" + file delete $tmp_filename + return + } + + set fd [open $tmp_filename "r"] + set result [read $fd] + close $fd + file delete $tmp_filename + return $result +} + + Index: openacs-4/packages/search/tcl/search-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-init.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/search/tcl/search-init.tcl 27 Apr 2004 12:09:18 -0000 1.6 +++ openacs-4/packages/search/tcl/search-init.tcl 8 Nov 2005 18:24:07 -0000 1.7 @@ -1 +1,6 @@ +nsv_set search_static_variables item_counter 0 + ad_schedule_proc -thread t [parameter::get_from_package_key -package_key search -parameter SearchIndexerInterval -default 60 ] search::indexer + +ad_schedule_proc -thread t 14400 db_dml optimize_intermedia_index {Ctx_Ddl.Optimize_Index ('swi_index','FAST', 60)} + 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/tcl/search-procs-oracle.xql 8 Nov 2005 18:24:07 -0000 1.7 @@ -0,0 +1,15 @@ + + + oracle8.1.6 + + + + select object_id, event_date, event + from search_observer_queue + where rownum < 100 + order by event_date asc + + + + + 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.29 -r1.30 --- openacs-4/packages/search/tcl/search-procs.tcl 12 Jun 2005 21:21:17 -0000 1.29 +++ openacs-4/packages/search/tcl/search-procs.tcl 8 Nov 2005 18:24:07 -0000 1.30 @@ -62,23 +62,30 @@ } } +ad_proc -public search::is_guest_p { +} { + Checks whether the logged-in user is a guest +} { + set user_id [ad_conn user_id] + return [db_string get_is_guest_p {select dotlrn_privacy.guest_p(:user_id) from dual}] +} -# ad_proc -public -callback search::action { -# -action -# -object_id -# -datasource -# -object_type -# } { -# Do something with a search datasource Called by the indexer -# after having created the datasource. +ad_proc -public -callback search::action { + -action + -object_id + -datasource + -object_type +} { + Do something with a search datasource Called by the indexer + after having created the datasource. -# @param action UPDATE INSERT DELETE -# @param datasource name of the datasource array + @param action UPDATE INSERT DELETE + @param datasource name of the datasource array -# @return ignored + @return ignored -# @author Jeff Davis (davis@xarg.net) -# } - + @author Jeff Davis (davis@xarg.net) +} - ad_proc -private search::indexer {} { @@ -99,7 +106,15 @@ return } # JCD: pull out the rows all at once so we release the handle - foreach row [db_list_of_lists search_observer_queue_entry {}] { + foreach row [db_list_of_lists search_observer_queue_entry {}] { + nsv_incr search_static_variables item_counter + if {[nsv_get search_static_variables item_counter] > 1000} { + nsv_set search_static_variables item_counter 0 + db_exec_plsql optimize_intermedia_index {begin + ctx_ddl.sync_index ('swi_index'); + end; + } + } foreach {object_id event_date event} $row { break } array unset datasource switch -- $event { @@ -127,7 +142,12 @@ if {![info exists datasource(package_id)]} { set datasource(package_id) "" } - callback -impl $driver search::index -object_id $object_id -content $txt -title $datasource(title) -keywords $datasource(keywords) -package_id $datasource(package_id) -datasource datasource + set datasource(community_id) [search::dotlrn::get_community_id -package_id $datasource(package_id)] + + if {![info exists datasource(relevant_date)]} { + set datasource(relevant_date) "" + } + 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 } else { acs_sc_call FtsEngineDriver \ [ad_decode $event UPDATE update_index index] \ @@ -247,9 +267,9 @@ foreach value $values { if {[string compare $default $value] == 0} { - lappend return_list "[lindex $items $count]" + lappend return_list "[lindex $items $count]" } else { - lappend return_list "[lindex $items $count]" + lappend return_list "[lindex $items $count]" } incr count @@ -274,25 +294,15 @@ # define for all objects, not just search? -ad_proc -callback search::index { - -object_id:required - -content:required - -title:required - -description - -keywords -} { - This callback is invoked by the search indexer. It will dispatch - to the full text search engine. Additional optional paramters may - be added to support additional features of full text search engines. -} - - ad_proc -callback search::search { -query:required -user_id {-offset 0} {-limit 10} {-df ""} - {-dt ""} + {-dt ""} + {-package_ids ""} + {-object_type ""} } { This callback is invoked when a search is to be performed. Query will be a list of lists. The first list is required and will be a @@ -323,9 +333,61 @@ -content -title -keywords + -community_id + -relevant_date + {-description ""} {-datasource ""} {-package_id ""} } { This callback is invoked from the search::indexer scheduled procedure to add an item to the index -} - \ No newline at end of file +} - + +ad_proc -callback search::update_index { + -object_id + -content + -title + -keywords + -community_id + -relevant_date + {-description ""} + {-datasource ""} + {-package_id ""} +} { + This callback is invoked from the search::indexer scheduled procedure + to update an item already in the index +} - + +ad_proc -callback search::summary { + -query + -text +} { + This callback is invoked to return an HTML fragment highlighting the terms in query +} - + +ad_proc -callback search::driver_info { +} { + This callback returns information about the search engine implementation +} - + +# dotlrn specific procs + +namespace eval search::dotlrn {} + +ad_proc -public search::dotlrn::get_community_id { + -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 + } + return "" +} \ No newline at end of file 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 -N -r1.6 -r1.7 --- openacs-4/packages/search/tcl/search-procs.xql 14 May 2004 10:17:36 -0000 1.6 +++ openacs-4/packages/search/tcl/search-procs.xql 8 Nov 2005 18:24:07 -0000 1.7 @@ -7,15 +7,7 @@ insert into search_observer_queue (object_id, event_date, event) values (:object_id, now(), :event) - - - - select object_id, event_date, event - from search_observer_queue - order by event_date asc - - - + select :content as content, Index: openacs-4/packages/search/www/advanced-search.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/advanced-search.adp,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/search/www/advanced-search.adp 10 Mar 2005 01:42:14 -0000 1.6 +++ openacs-4/packages/search/www/advanced-search.adp 8 Nov 2005 18:24:07 -0000 1.7 @@ -1,25 +1,25 @@ - #search.Advanced_Search# - "advanced search" - noindex,nofollow +#search.Advanced_Search# +"advanced search" -
- - -

#search.Date_Range# - - #search.Display# -

-
+
+ + +
+#search.Date_Range# + +#search.nbspDisplay# + +
Index: openacs-4/packages/search/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/index.adp,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/search/www/index.adp 10 Mar 2005 01:42:14 -0000 1.7 +++ openacs-4/packages/search/www/index.adp 8 Nov 2005 18:24:07 -0000 1.8 @@ -1,16 +1,16 @@ - #search.Search# - #search.Search# - noindex,nofollow +#search.Search# +#search.Search# - -
- - - -
- #search.Advanced_Search# -
- - #search.no_driver_contact_webmaster# - +
+
+ + #search.Advanced_Search# +
+ +
+ + +
+
+
Index: openacs-4/packages/search/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/index.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/search/www/index.tcl 2 Feb 2005 21:18:03 -0000 1.3 +++ openacs-4/packages/search/www/index.tcl 8 Nov 2005 18:24:07 -0000 1.4 @@ -1,14 +1,2 @@ -ad_page_contract { - @author Jeff Davis - @creation-date 2005-02-01 - @cvs-id $Id$ -} {} - -set driver [ad_parameter -package_id [ad_conn package_id] FtsEngineDriver] -array set info [acs_sc_call FtsEngineDriver info [list] $driver] -if { [array get info] == "" } { - # no driver present need a warning. - set driver_p 0 -} else { - set driver_p 1 -} +# Nothing to see here... +ad_return_template \ No newline at end of file Index: openacs-4/packages/search/www/search.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/search.adp,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/search/www/search.adp 10 Mar 2005 01:42:14 -0000 1.7 +++ openacs-4/packages/search/www/search.adp 8 Nov 2005 18:24:07 -0000 1.8 @@ -1,102 +1,97 @@ - @page_title@ - @context;noquote@ - t - noindex,nofollow - - - - - -
- - - -
-

#search.Advanced_Search#

+ + + #search.lt_Tip_In_most_browsers_#

+

#search.lt_You_must_specify_some#

- -

#search.and_not_needed# [#search.details#]

-
- -

#search.lt_bstopwordsb_is_a_very# [#search.details#]

-
- -

#search.lt_The_following_words_a# [#search.details#]

-
+ + + #search.The# + [#search.details#]
+
+
+ + + #search.lt_bstopwordsb_is_a_very# + [#search.details#]
+
+
+ + + #search.lt_The_following_words_a# @stopwords@. + [#search.details#]
+
+
- -
- - #search.Untitled# - - - - - -
@searchresult.txt_summary;noquote@
-
-
@searchresult.url_one@
-
-
+ + + #search.Untitled#
+
+ + @searchresult.title_summary;noquote@
+
+ + + + @searchresult.txt_summary;noquote@
+
+ @searchresult.url_one@

+
- -

#search.lt_No_pages_were_found_c#

-

#search.Suggestions#

-
    -
  • #search.lt_Make_sure_all_words_a#
  • -
  • #search.lt_Try_different_keyword#
  • -
  • #search.lt_Try_more_general_keyw#
  • - -
  • #search.Try_fewer_keywords#
  • -
    -
+ + Your search - @query@ - did not match any content. +
#search.lt_No_pages_were_found_c#@query@". +

#search.Suggestions# +
    +
  • #search.lt_Make_sure_all_words_a# +
  • #search.lt_Try_different_keyword# +
  • #search.lt_Try_more_general_keyw# + +
  • #search.Try_fewer_keywords# - -

    #search.Searched_for_query#

    -

    #search.Results_count#

    -
    +
+
+ + + +
+ + #search.Searched_for_query# + + + + #search.Results# @low@-@high@ #search.of_about# @count@#search.________Search_took# @elapsed@ #search.seconds# + +
+
+
- -
- #search.Result_page# - - #search.Previous# - -  @choice_bar;noquote@  - - #search.Next# - -
-
- -
-
- - -
-
+ +
- -

#search.lt_Try_your_query_on_stw#

-
+ #search.Result_page# + + + #search.Previous# - +  @choice_bar;noquote@  + + + #search.Next# + +
+
+ +
+ +
+ + +
+ #search.lt_Try_your_query_on_stw#
+ +
+
+
\ No newline at end of file Index: openacs-4/packages/search/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/search.tcl,v diff -u -N -r1.18 -r1.19 --- openacs-4/packages/search/www/search.tcl 12 Jun 2005 21:21:51 -0000 1.18 +++ openacs-4/packages/search/www/search.tcl 8 Nov 2005 18:24:08 -0000 1.19 @@ -9,6 +9,9 @@ {num:integer 0} {dfs:trim ""} {dts:trim ""} + {search_package_id ""} + {scope ""} + {object_type "all"} } set page_title "Search Results" @@ -23,20 +26,34 @@ set user_id [ad_conn user_id] set driver [ad_parameter -package_id $package_id FtsEngineDriver] -array set info [acs_sc_call FtsEngineDriver info [list] $driver] +if {[callback::impl_exists -impl $driver -callback search::driver_info]} { + array set info [lindex [callback -impl $driver search::driver_info] 0] +# array set info [list package_key intermedia-driver version 1 automatic_and_queries_p 1 stopwords_p 1] +} else { + array set info [acs_sc_call FtsEngineDriver info [list] $driver] +} +set dotlrn_package_id [dotlrn::get_package_id] +set is_guest_p [search::is_guest_p] +# Ugly .LRNism: guests must not search for people. Here's the security +# check that makes sure they cannot fiddle around with the URL +if {$is_guest_p && [string equal $object_type "phb_person"]} { + ad_return_error "Security Breakin!" "Security Alert. This incident has been logged." +} if { [array get info] == "" } { ReturnHeaders ns_write "[_ search.lt_FtsEngineDriver_not_a]" ad_script_abort } -if {[string is space $q] } { +if {[string equal "" [string trim $q]]} { set query {} set empty_p 1 set url_advanced_search "advanced-search" - ad_return_template + ad_return_template + # FIXME DAVEB I don't understand why I can't call ad_script_abort here instead of return.... + # if I call ad_script_abort the adp is never rendered return } else { set empty_p 0 @@ -68,7 +85,7 @@ set dt [db_exec_plsql get_dt "select now() + '$symbol2interval($dts)'::interval"] } -set q [string tolower $q] +#set q [string tolower $q] set urlencoded_query [ad_urlencode $q] if { $offset < 0 } { set offset 0 } @@ -82,9 +99,24 @@ } set t0 [clock clicks -milliseconds] + +# TODO calculate subsite or dotlrn package_ids +if {![string equal "this" $scope]} { + # don't send package_id if its not searching this package + set search_package_id "" +} else { + set search_node_id [site_node::get_node_id_from_object_id -object_id $search_package_id] + if {[string equal "dotlrn" [site_node::get_element -node_id $search_node_id -element package_key]]} { + set search_package_id [site_node::get_children -node_id $search_node_id -element package_id] + } +} + if {[callback::impl_exists -impl $driver -callback search::search]} { # DAVEB TODO Add subsite to the callback def? - array set result [lindex [callback -impl $driver search::search -query $q -offset $offset -limit $limit -user_id $user_id -df $df] 0] + # FIXME do this in the intermedia driver! +# set final_query_string [db_string final_query_select "select site_wide_search.im_convert(:q) from dual"] + + array set result [lindex [callback -impl $driver search::search -query $q -offset $offset -limit $limit -user_id $user_id -df $df -package_ids $search_package_id -object_type $object_type] 0] } else { array set result [acs_sc_call FtsEngineDriver search $params $driver] } @@ -93,7 +125,11 @@ if { $t == "Feeling Lucky" && $result(count) > 0} { set object_id [lindex $result(ids) 0] set object_type [acs_object_type $object_id] - set url [acs_sc_call FtsContentProvider url [list $object_id] $object_type] + if {[callback::impl_exists -impl -callback search::url]} { + set url [callback -impl $object_type search::url -object_id $object_id] + } else { + set url [acs_sc_call FtsContentProvider url [list $object_id] $object_type] + } ad_returnredirect $url ad_script_abort } @@ -126,13 +162,22 @@ set object_id [lindex $result(ids) $__i] set object_type [acs_object_type $object_id] - ns_log notice "\n------\nDAVEB search\n object_id='${object_id}' object_type='${object_type}'\n-----\n" - array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] + if {[callback::impl_exists -impl $object_type -callback search::datasource]} { + array set datasource [lindex [callback -impl $object_type search::datasource -object_id $object_id] 0] + set url_one [lindex [callback -impl $object_type search::url -object_id $object_id] 0] + } else { + ns_log notice "SEARCH search/www/search.tcl callback::datasource::${object_type} not found" + array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] + set url_one [acs_sc_call FtsContentProvider url [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] - set txt_summary [acs_sc_call FtsEngineDriver summary [list $q $txt] $driver] - set url_one [acs_sc_call FtsContentProvider url [list $object_id] $object_type] - + if {[callback::impl_exists -impl $driver -callback search::summary]} { + set title_summary [lindex [callback -impl $driver search::summary -query $q -text $datasource(title)] 0] + set txt_summary [lindex [callback -impl $driver search::summary -query $q -text $txt] 0] + } else { + set title_summary [acs_sc_call FtsEngineDriver summary [list $q $datasource(title)] $driver] + set txt_summary [acs_sc_call FtsEngineDriver summary [list $q $txt] $driver] + } template::multirow append searchresult $title_summary $txt_summary $url_one } @@ -180,4 +225,3 @@ } set choice_bar [search::choice_bar $items $links $values $current_result_page] - Index: openacs-4/packages/search/www/admin/delete-object-type-from-index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/delete-object-type-from-index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/delete-object-type-from-index.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Search admin index page + + @author openacs@dirkgomez.de +} { + object_type + +} -properties { +} +db_dml delete_object_type_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type=:object_type)} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/index-missing-objects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/index-missing-objects.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/index-missing-objects.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,20 @@ +ad_page_contract { + index items of an object type which are not yet indexed + + @author openacs@dirkgomez.de +} { + object_type +} -properties { +} + +if {[string equal $object_type "file_storage_object"]} { + db_dml reindex_file_storage_object { + insert into search_observer_queue (object_id, event) + select object_id, 'INSERT' from acs_objects, cr_items + where object_id=live_revision and + object_type in ('file_storage_object') and + object_id + not in (select object_id from site_wide_index)} +} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/index.adp 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,66 @@ + +Search Admin Page +@context;noquote@ + + + + + + + + + + + + + + + +
Object Type#Objects in the Index#Objects that should be in the Index
@object_type_count.object_type@@object_type_count.count_object_type@ + + @count_cal_item@ + @count_file_storage_object@ + @count_static_portal_content@ + @count_forums_message@ + @count_forums_forum@ + @count_news@ + @count_faq@ + @count_survey@ + @count_phb_person@ + + Delete @object_type_count.object_type@ from index
+ +

Search Observer Queue

+ +

Items in the search observer queue: @search_observer_queue_count@ + +

Reindexing

+ + +

Index objects missing from the index

+ + +

Index particular objects

+

+

+ + +
+ +

+

+ + +
Index: openacs-4/packages/search/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/index.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,38 @@ +ad_page_contract { + Search admin index page + + @author openacs@dirkgomez.de +} -properties { +} +set context [list "Search Admin Page"] + +db_multirow object_type_count object_type_count { + select object_type, + count(swi.object_id) as count_object_type + from acs_objects ao, site_wide_index swi + where swi.object_id=ao.object_id + group by object_type + order by object_type} + +db_1row get_cal_item {select count(*) as count_cal_item from acs_objects where object_type in ('cal_item') } + +db_1row get_file_storage_object {select count(*) as count_file_storage_object from acs_objects, cr_items where object_id=live_revision and object_type in ('file_storage_object') } + +db_1row get_static_portal_content {select count(*) as count_static_portal_content from acs_objects where object_type in ('static_portal_content')} + +db_1row get_forums_message {select count(*) as count_forums_message from acs_objects where object_type in ('forums_message') } + +db_1row get_forums_forums {select count(*) as count_forums_forum from acs_objects where object_type in ('forums_forum') } + +db_1row get_news {select count(*) as count_news from acs_objects, cr_items, cr_news where news_id=live_revision and object_id=live_revision and object_type in ('news')} + +db_1row get_faq {select count(*) as count_faq from acs_objects where object_type in ('faq') } + +db_1row get_survey {select count(*) as count_survey from acs_objects where object_type in ('survey')} + +db_1row get_phb_person {select count(*) as count_phb_person from acs_objects,cr_items where object_type in ('phb_person') and object_id=live_revision } + +db_1row get_search_observer_queue_count { + select count(*) as search_observer_queue_count + from search_observer_queue +} \ No newline at end of file Index: openacs-4/packages/search/www/admin/list-object.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/list-object.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/list-object.adp 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,7 @@ + +Search Admin Page +@context;noquote@ +

Object Name: @object_name@ +

Indexed Content: @indexed_content@ +

Package ID: @package_id@ +

Community ID: @community_id@ Index: openacs-4/packages/search/www/admin/list-object.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/list-object.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/list-object.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + Search admin index page + + @author openacs@dirkgomez.de +} { + object_id + +} -properties { +} +set context [list "Search Admin Page"] + +db_1row get_object_content { + select object_name, indexed_content, package_id, community_id + from site_wide_index swi + where object_id=:object_id + order by object_id} \ No newline at end of file Index: openacs-4/packages/search/www/admin/list-objects.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/list-objects.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/list-objects.adp 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,11 @@ + +Search Admin Page +@context;noquote@ + + + + + + + +
Object TypeObjects in the Index
@objects_per_type.object_id@@objects_per_type.object_name@
\ No newline at end of file Index: openacs-4/packages/search/www/admin/list-objects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/list-objects.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/list-objects.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + Search admin index page + + @author openacs@dirkgomez.de +} { + object_type + +} -properties { +} +set context [list "Search Admin Page"] + +db_multirow objects_per_type objects_per_type { + select object_name, swi.object_id + from acs_objects ao, site_wide_index swi + where swi.object_id=ao.object_id + and ao.object_type=:object_type + order by object_id} \ No newline at end of file Index: openacs-4/packages/search/www/admin/reindex-calitem.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-calitem.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-calitem.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex CAL_ITEM + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_cal_item_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='cal_item')} +db_dml reindex_cal_item { + insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('cal_item')} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-faq.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-faq.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-faq.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex FAQ + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_faq_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='faq')} +db_dml reindex_faq { + insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('faq')} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-file-storage.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-file-storage.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-file-storage.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex FILE_STORAGE_OBJECT + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_file_storage_object_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='file_storage_object')} +db_dml reindex_file_storage_object { +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects, cr_items where object_id=live_revision and object_type in ('file_storage_object') } + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-forums-message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-forums-message.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-forums-message.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex FORUMS_MESSAGE + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_forums_message_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='forums_message')} +db_dml reindex_forums_message { + insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('forums_message')} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-forums.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-forums.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-forums.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex FORUMS_FORUM + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_forums_forum_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='forums_forum')} +db_dml reindex_forums_forum { + insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('forums_forum')} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-news.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-news.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-news.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex NEWS + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_news_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='news')} +db_dml reindex_news { +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects, cr_items, cr_news where news_id=live_revision and object_id=live_revision and object_type in ('news')} +# and archive_date is null +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-one-item.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-one-item.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-one-item.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex one item + + @author openacs@dirkgomez.de +} { + object_id +} -properties { +} +db_dml reindex_forums_message { + insert into search_observer_queue (object_id, event) values (:object_id, 'UPDATE')} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-phb-person.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-phb-person.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-phb-person.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex PHB_PERSON + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_phb_person_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='phb_person')} +db_dml reindex_phb_person { +insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects,cr_items where object_type in ('phb_person') and object_id=live_revision } + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-static-portal.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-static-portal.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-static-portal.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex STATIC_PORTAL_CONTENT + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_static_portal_content_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='static_portal_content')} +db_dml reindex_static_portal_content { + insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('static_portal_content')} + +ad_returnredirect ./index Index: openacs-4/packages/search/www/admin/reindex-survey.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/admin/Attic/reindex-survey.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/admin/reindex-survey.tcl 8 Nov 2005 18:24:08 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Reindex SURVEY + + @author openacs@dirkgomez.de +} { +} -properties { +} +db_dml delete_survey_from_index {delete from site_wide_index where object_id in (select object_id from acs_objects where object_type='survey')} +db_dml reindex_survey { + insert into search_observer_queue (object_id, event) select object_id, 'INSERT' from acs_objects where object_type in ('survey')} + +ad_returnredirect ./index