| Revision 75 (by dpavlin, 2006/08/07 23:22:29) |
minor modificaton to cross-link documentation and actually transfer all of
it to pgfoundry.org |
=head1 pgestraier Tutorial
This tutorial will try to show how easy it is to replace SQL
constructs that use C<< where column like '%something%' >>
with external full-text index using
L<Hyper Estraier|http://hyperestraier.sourceforge.net/>.
In less then 10 minutes from installation to fill-text search-able table
(speed may vary somewhat, but it's really fast).
=head2 Installation
$ sudo apt-get install postgresql-8.1 postgresql-server-dev-8.1 \
libdbd-pg-perl
$ sudo cpan Search::Estraier
=head2 Compilation
$ cd pgestraier
$ sudo make install
This will just install library at right place without running tests or examples.
=head2 Creating full-text index
Let's assume you have database called C<content> in which you have table
C<new> which has fields title, lead, content, keywords and source which
should be search-able.
You will have to do:
$ ./bin/pgest-index.pl content --create news > search.sql
That's it. Really. You will even get example SQL query to shoehorn into
your application.
You can now connect to database using psql, edit search string in
C<search.sql> and try your new full-text index.
However, you will notice that we indexed B<every> field in table news,
which is wasteful (because other fields are ids of various things,
booleans and fields which aren't interesting for full-text search).
So, we can do better:
$ ./bin/pgest-index.pl content --create news \
--sql="select id,title,lead,content,keywords from news"
We added custom SQL query which will be used to produce full-text index and
triggers so that we touch only columns in which we are really interested.
This time around that it! Enjoy.
For all available options see L<pgest-index> documentation.