F.39. tsearch2

Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.

The tsearch2 module provides backwards-compatible text search functionality for applications that used tsearch2 before text searching was integrated into core PostgreSQL in release 8.3.

F.39.1. Portability Issues

Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.

Although the built-in text search features were based on tsearch2 and are largely similar to it, there are numerous small differences that will create portability issues for existing applications:

There are some issues that are not addressed by the replacement tsearch2 module, and will therefore require application code changes in any case:

F.39.2. Converting a pre-8.3 Installation

Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.

The recommended way to update a pre-8.3 installation that uses tsearch2 is:

  1. Make a dump from the old installation in the usual way, but be sure not to use -c (--clean) option of pg_dump or pg_dumpall.

  2. In the new installation, create empty database(s) and install the replacement tsearch2 module into each database that will use text search. This must be done before loading the dump data! If your old installation had the tsearch2 objects in a schema other than public, be sure to adjust the CREATE EXTENSION command so that the replacement objects are created in that same schema.

  3. Load the dump data. There will be quite a few errors reported due to failure to recreate the original tsearch2 objects. These errors can be ignored, but this means you cannot restore the dump in a single transaction (eg, you cannot use pg_restore's -1 switch).

  4. Examine the contents of the restored tsearch2 configuration tables (pg_ts_cfg and so on), and create equivalent built-in text search configurations as needed. You may drop the old configuration tables once you've extracted all the useful information from them.

  5. Test your application.

At a later time you may wish to rename application references to the alias text search objects, so that you can eventually uninstall the replacement tsearch2 module.

F.39.3. References

Tsearch2 Development Site http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/