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
- OpenACS 5.x
- PostgreSQL 7.3 or newer
- PostgreSQL's tsearch2 module installed. (Pg versions 7.3 and 7.4 require a patch and tsearch2.sql to be loaded into the database)
- This package installed
- search package to be mounted somewhere.
- FtsEngineDriver parameter of search package set to "tsearch2-driver".
- indexing some data
Install OpenACS' Tsearch2 Full-Text Search Package
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 thesearch
line.Type
search
where it saysuntitled
, choosesearch
from the drop-down list, and click.
Click the
Parameters
link next to the Search package instance.Type
tsearch2-driver
where it saysopenfts-driver
in theFtsEngineDriver
parameter.
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.
-
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.
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:
- packages/edit-this-page/sql/postgresql/edit-this-page-sc-create.sql
- packages/lars-blogger/sql/postgresql/lars-blogger-sc-create.sql
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