Tsearch2 Driver provides full-text searching of a PostgreSQL database by using PostgreSQL's tsearch2 FtsEngineDriver
If you have not yet, install PostgreSQL's tsearch2 module.
      Click Admin on the top of the
      default home page. If prompted, log in with the account and
      password you entered during install.
    
      Click on the Install
      software link.
    
      Click on the Install new
      service link.
    
      Click on the Install link next to
      Tsearch2 Driver. If you have installed tsearch2 into your
      PostgreSQL database, the installer will automatically enable
      tsearch in your OpenACS database instance.
    
Restart AOLserver. Wait a minute, then browse back to the home page.
      Click on Admin on the top of the
      screen.
    
      Click on Main Site
      Administration in the "Subsite
      Administration" section.
    
      Click on Site
      Map in the "Advanced Features" section.
    
Mount the Search interface in the site-map.
          Click the new sub
          folder link on the Main Site line. 
        
          Type search
          and click . 
        
          Click the new
          application link on the search line. 
        
          Type search
          where it says untitled, choose search from the
          drop-down list, and click . 
        
          Click the Parameters link next
          to the Search package instance.
        
          Type tsearch2-driver
          where it says openfts-driver in the
          FtsEngineDriver
          parameter. 
        
      Restart AOLserver. 
      Wait a minute, then click on Main
      Site at the top of the page.
    
Weblogger (lars-blogger), ETP (edit-this-page), and a few other packages have code to generate indexed content. We are using lars-blogger to illustrate how to enable Full Text Search in packages.
Install the lars-blogger package, if it is not yet installed.
          Click Admin on the top of
          the default home page. If prompted, log in with the account
          and password you entered during install.
        
          Click on the Install
          software link.
        
          Click on the Install new
          application link.
        
          Click on the Install link next to
          Weblogger.
        
Install all required packages as well (always say okay until you shall restart the server)
Loading the service contracts datamodel and enabling the service contract usually happens when the package is installed. However, Lars-blogger may require manually loading lars-blogger-sc-create.sql to get it to register the service contract implementation that indexes the content:
[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$cd packages/lars-blogger/sql/postgresql[$OPENACS_SERVICE_NAME postgresql]$psql $OPENACS_SERVICE_NAME -f lars-blogger-sc-create.sql
Restart AOLserver.
Full Text Search should be enabled now, if not consult http://openacs.org/forums/message-view?message_id=154759. This link also contains some hints on how to make sure it is enabled.
Once tsearch2-driver is installed, add some content to be indexed.
Standard coding practice is to put indexing code in package-key/sql/postgresql/package-key-sc-create.sql. View these examples for how to implement:
If your pre-existing content has been indexed before (e.g. because the search package was mounted before as part of a previous search service), you have to tell the search package to reindex:
    insert into search_observer_queue (
            select my_id, now(),'INSERT' from my_table
            );
  For forums and ETP this looks like:
    insert into search_observer_queue (
            select message_id, now(), 'INSERT' from forums_messages
            );
    insert into search_observer_queue (
            select live_revision, now(), 'INSERT' from (
                    select live_revision from cr_items where content_type = 'etp_page_revision'
                    ) 
            etp );
  This version includes only the most basic features. Many options are possible by adding admin configurable parameters. The current service contract definitions are not flexible enough to work well with every possible search driver, so some features may require making some improvements to the search package also.
Dave Bauer dave@thedesignexperience.org 2004-06-05