PostgreSQL & PHP Tutorials - Installing Full Text Indexing

PostgreSQL »  Introduction to Full Text Indexing

Posted By Chris Smith Posted on 26 Mar 2006, 07:00 AM
Viewing page 1 of 3
« | Back | Next | »

Full text indexing will make searching in large amounts of text quite quick. It isn't built into PostgreSQL, rather it's available through an external ('contrib') module called 'TSearch2'.

There was a 'tsearch' module so don't get them confused. TSearch was available before version 8.0 and will be deprecated in the future.

Installing tsearch2 is quite easy. Once you install the contrib package, find the tsearch2.sql file and import it:

psql -d databasename < /path/to/tsearch2.sql

for example:

$ psql -d mydatabase < /usr/share/postgresql/contrib/tsearch2.sql

It will run through a series of commands (CREATE FUNCTION and CREATE OPERATOR) and then finish installing.

If you log in to psql:

psql -d mydatabase

and run \d to print out a list of tables, you will see extra tables:

public | pg_ts_cfg | table | tomcat
public | pg_ts_cfgmap | table | tomcat
public | pg_ts_dict | table | tomcat
public | pg_ts_parser | table | tomcat

We don't need to worry about these tables or what they do at the moment.

Now that's installed, we need to add full text indexing to our table.
Viewing page 1 of 3
« | Back | Next | »

Avg Rating: 4
Vote Count: 14


  New Reply

Very nice intro guide. Good work. Rodrigo 12 Apr 2006 Reply

Want to post a comment? Fill in the details below.

Your Name  : 
Your Email  : 
Your Website  : 
Spam Check! Please answer this question  : 8 + 6 =