Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 30 Mar 2001 05:31:33 -0000 1.7 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 1 Apr 2001 15:03:49 -0000 1.8 @@ -909,8 +909,9 @@ -- prompt *** Creating object types... \i types-create.sql +-- DC@: oracle-specific code that can't be directly ported to postgresql. -- prompt *** Preparing search indices... -\i content-search.sql +-- \i content-search.sql -- this index requires prefs created in content-search -- create index cr_doc_filter_index on cr_doc_filter ( content ) Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-search.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-search.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-search.sql 1 Apr 2001 15:03:49 -0000 1.1 @@ -0,0 +1,111 @@ +------------------------------------------------------------ +-- Set up an index with INSO filtering on the content column +------------------------------------------------------------ + +-- DCW: oracle specific code that can't be directly ported to postgresql. + +/* +set serveroutput on + +declare + v_exists integer; +begin + + -- Check whether the preference already exists + select decode(count(*),0,0,1) into v_exists from ctx_user_preferences + where pre_name = 'CONTENT_FILTER_PREF'; + + if v_exists = 0 then + + dbms_output.put_line('Creating content filter preference...'); + + ctx_ddl.create_preference + ( + preference_name => 'CONTENT_FILTER_PREF', + object_name => 'INSO_FILTER' + ); + + end if; + +end; +/ + +create index cr_rev_content_index on cr_revisions ( content ) + indextype is ctxsys.context + parameters ('FILTER content_filter_pref' ); + +alter index cr_rev_content_index rebuild online parameters ('sync'); +*/ +------------------------------------------------------------ +-- Set up an XML index for searching attributes +------------------------------------------------------------ + +-- To find the word company in the title only: + +-- select revision_id,score(1) +-- from cr_revision_attributes +-- where contains(attributes, 'company WITHIN title', 1) > 0; + +-- use a direct datastore rather than setting up a user datastore +-- this avoids having to generate an XML document for every +-- revision every time the index is rebuilt. It also avoids the +-- cumbersome manual process of setting up a user datastore. +/* +create or replace package content_search is + + procedure update_attribute_index; + +end content_search; +/ +show errors + +create or replace package body content_search is + +procedure update_attribute_index is +begin + + for c1 in (select revision_id from cr_revisions r where not exists ( + select 1 from cr_revision_attributes a + where a.revision_id = r.revision_id)) loop + + content_revision.index_attributes(c1.revision_id); + commit; + + end loop; + +end update_attribute_index; + +end; +/ +show errors + +declare + v_exists integer; +begin + + -- Check whether the section group already exists + select decode(count(*),0,0,1) into v_exists from ctx_user_section_groups + where sgp_name = 'AUTO'; + + if v_exists = 0 then + + dbms_output.put_line('Creating auto section group for attribute index...'); + + ctx_ddl.create_section_group('auto', 'AUTO_SECTION_GROUP'); + + end if; +end; +/ + +create index cr_rev_attribute_index on cr_revision_attributes ( attributes ) + indextype is ctxsys.context + parameters ('filter ctxsys.null_filter section group auto' ); + +begin + content_search.update_attribute_index; +end; +/ +show errors + +alter index cr_rev_attribute_index rebuild online parameters ('sync'); +*/