{/doc/tsearch2-driver {Tsearch2 Driver}} {Tsearch2 Full-text Search Engine Driver for OpenACS 5.x} Tsearch2 Full-text Search Engine Driver for OpenACS 5.x

Tsearch2 Full-text Search Engine Driver for OpenACS 5.x

Tsearch2 Driver provides full-text searching of a PostgreSQL database by using PostgreSQL's tsearch2 FtsEngineDriver

Requirements for this search implementation

Install OpenACS' Tsearch2 Full-Text Search Package

  1. If you have not yet, install PostgreSQL's tsearch2 module.

  2. Click Admin on the top of the default home page. If prompted, log in with the account and password you entered during install.

  3. Click on the Install software link.

  4. Click on the Install new service link.

  5. 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.

  6. Restart AOLserver. Wait a minute, then browse back to the home page.

  7. Click on Admin on the top of the screen.

  8. Click on Main Site Administration in the "Subsite Administration" section.

  9. Click on Site Map in the "Advanced Features" section.

  10. Mount the Search interface in the site-map.

    1. Click the new sub folder link on the Main Site line.

    2. Type search and click New.

    3. Click the new application link on the search line.

    4. Type search where it says untitled, choose search from the drop-down list, and click New.

    5. Click the Parameters link next to the Search package instance.

    6. Type tsearch2-driver where it says openfts-driver in the FtsEngineDriver parameter.

  11. Restart AOLserver. Wait a minute, then click on Main Site at the top of the page.

Enable Full Text Search in packages

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.

  1. Install the lars-blogger package, if it is not yet installed.

    1. Click Admin on the top of the default home page. If prompted, log in with the account and password you entered during install.

    2. Click on the Install software link.

    3. Click on the Install new application link.

    4. Click on the Install link next to Weblogger.

    5. Install all required packages as well (always say okay until you shall restart the server)

  2. 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
    
  3. 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.

Indexing data

Once tsearch2-driver is installed, add some content to be indexed.

Adding search indexing to packages

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:

Indexing pre-existing content that has been indexed before

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 );

Implementation notes

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.

Release Notes

Please file bugs in the Bug Tracker.

Dave Bauer dave\@thedesignexperience.org 2004-06-05