19 |
|
|
20 |
=item * |
=item * |
21 |
|
|
22 |
PostgreSQL (tested with version 7.4.8) with development libraries |
PostgreSQL (tested with versions 7.4 and 8.0) with development libraries |
23 |
|
|
24 |
=item * |
=item * |
25 |
|
|
26 |
Hyper Estraier (tested with versions 0.3.9 and 0.3.10) |
Hyper Estraier (tested with various versions, recommended 1.2.4 of newer) |
27 |
|
|
28 |
=back |
=back |
29 |
|
|
37 |
|
|
38 |
=item * |
=item * |
39 |
|
|
40 |
perl modules C<DBI>, C<DBD::Pg>, C<Test::More> and optionally C<HyperEstraier> |
perl modules C<DBI>, C<DBD::Pg>, C<Test::More> and optionally C<Search::Estraier> |
41 |
|
|
42 |
=item * |
=item * |
43 |
|
|
44 |
C<trivia.list.gz> from Internet Movie Database in data/ directory |
C<trivia.list.gz> from Internet Movie Database in C<data/> directory |
45 |
|
|
46 |
=item * |
=item * |
47 |
|
|
48 |
database "test" with permissions for current user |
PostgreSQL database C<test> with permissions for current user |
49 |
|
|
50 |
|
=item * |
51 |
|
|
52 |
|
Hyper Estraier node C<trivia> with permissions for C<admin> user. |
53 |
|
|
54 |
=back |
=back |
55 |
|
|
58 |
make |
make |
59 |
|
|
60 |
and see sample results. You will be asked your password once (via sudo) to |
and see sample results. You will be asked your password once (via sudo) to |
61 |
install pgest.so shared library in system-wide location so that PostgreSQL |
install C<pgest.so> shared library in system-wide location so that PostgreSQL |
62 |
could access it. |
could access it. |
63 |
|
|
64 |
Next, you will have to create test index. You have two options: |
=head2 Create sample index using Hyper Estraier perl bindings |
65 |
|
|
66 |
=head2 Create index using estcmd |
Perl bindings for Hyper Estraier are available at CPAN: |
67 |
|
|
68 |
This will create temporary files on disk and index them using estcmd gather |
L<http://search.cpan.org/~dpavlin/Search-Estraier/> |
69 |
|
|
|
cd data |
|
|
make index |
|
|
cd .. |
|
70 |
|
|
71 |
B<Warning:> this method is incomplete and won't create node index needed |
After installing C<Search::Estraier> you can create index using following commands: |
|
to run last examples in C<test.sql> correctly. Solution is simple: either |
|
|
symlink your newly created index to Hyper Estraier C<_node> directory or |
|
|
create node and fill re-create index using C<estcall>. |
|
|
|
|
|
=head2 Create index using Hyper Estraier perl bindings |
|
|
|
|
|
For this, you will have to install perl bindings from |
|
|
|
|
|
L<http://hyperestraier.sourceforge.net/binding/> |
|
|
|
|
|
If you installed bindings as documented in README file, you can use |
|
|
perl binding to create index about three times faster. However, you will |
|
|
fist need to create node I<trivia> using Hyper Estraier's administration |
|
|
interface at L<http://localhost:1978/masterui>. You will also need user |
|
|
C<admin> with password C<admin> because those values are hard-coded in |
|
|
C<indexer.pl>. If you want to use different user on index name, feel |
|
|
free to change script. |
|
72 |
|
|
73 |
cd data |
cd data |
74 |
make perl |
make index |
75 |
cd .. |
cd .. |
76 |
|
|
77 |
To run tests (which require that you have estcmd in your $PATH) issue |
To run tests (which require that you have estcmd in your $PATH) issue |
78 |
|
|
79 |
make test |
make test |
80 |
|
|
81 |
See also included file test.sql for more examples of usage. |
See also included file C<test.sql> for more examples of usage. |
82 |
|
|
83 |
=head1 Usage of pgest from SQL |
=head1 Usage of pgest from SQL |
84 |
|
|
85 |
C<pgest> PostgreSQL function has two different prototypes (number of arguments) depending on usage. |
C<pgest> PostgreSQL function tries to mimic usage of normal database tables (with support for attribute filtering, limit and offset) in following way: |
86 |
|
|
87 |
SELECT |
SELECT |
88 |
-- columns to return (defined later) |
-- columns to return (defined later) |
89 |
id,title,size |
id,title,size |
90 |
FROM pgest( |
FROM pgest( |
91 |
-- path to index OR URL to node, user-name and password |
-- node URI, login, password and depth of search |
92 |
-- you will need JUST ONE of following two lines, depending |
'http://localhost:1978/node/trivia', 'admin', 'admin', 42, |
|
-- on your usage described below |
|
|
'/full/path/to/casket', |
|
|
'http://localhost:1978/node/trivia', 'admin', 'admin', |
|
93 |
-- query |
-- query |
94 |
'blade runner', |
'blade runner', |
95 |
-- additional attributes, use NULL or '' to disable |
-- additional attributes, use NULL or '' to disable |
108 |
id text, title text, size text |
id text, title text, size text |
109 |
); |
); |
110 |
|
|
111 |
|
You should note that Hyper Estraier uses UTF-8 encoding, while your |
112 |
|
PostgreSQL installation might use different encoding. To fix that, use |
113 |
|
C<convert> function in PostgreSQL to convert encodings. |
114 |
|
|
115 |
|
=head2 Using index via C<estmaster> server process |
116 |
|
|
117 |
|
This is default and recommended way to use C<pgest> functionality. In this |
118 |
|
case, C<pgest> will use node API and access index through C<estmaster> |
119 |
|
process which should be running on (local or remote) machine. |
120 |
|
|
121 |
|
This will remove database opening overhead, at a cost of (small) additional network |
122 |
|
traffic. However, you can have Hyper Estraier C<estmaster> process running on |
123 |
|
different machine or update index while doing searches, so benefits of this |
124 |
|
approach are obvious. |
125 |
|
|
126 |
=head2 Accessing database directly |
=head2 Accessing database directly |
127 |
|
|
128 |
If you want to access database directly (without running C<estmaster> process), first argument is full path to database file. |
B<Please note that direct access to database is depreciated.> As such, it's |
129 |
|
not stated in example, and it's kept just for backward compatibility, but it |
130 |
|
will probably be removed in future versions of C<pgest>. |
131 |
|
|
132 |
|
If you want to access database directly (without running C<estmaster> process), you |
133 |
|
have to replace node URI, login, password and depth with full path to database file. |
134 |
|
|
135 |
Have in mind that C<postgres> user under which PostgreSQL is running must |
Have in mind that C<postgres> user under which PostgreSQL is running must |
136 |
have read permission on Hyper Estraier database files. |
have read permission on Hyper Estraier database files. |
139 |
index grows bigger, you might consider using node API to remove overhead of |
index grows bigger, you might consider using node API to remove overhead of |
140 |
database opening on each query. |
database opening on each query. |
141 |
|
|
|
=head2 Using index via C<estmaster> server process |
|
|
|
|
|
If first argument is URL to node (like C<http://localhost:1978/node/trivia>) |
|
|
and there are two additional parameters (user-name and password) after it, |
|
|
C<pgest> will use node API and access index through C<estmaster> process which should be running on (local or remote) machine. |
|
|
|
|
|
This will remove database opening overhead, at a cost of additional network |
|
|
traffic. However, you can have Hyper Estraier C<estmaster> process running on |
|
|
different machine or update index while doing searches, so benefits of this |
|
|
approach are obvious. |
|
|
|
|
|
B<Note:> Currently, there is no support to search more than one index (depth |
|
|
of search is always 0). This will be fixed. |
|
|
|
|
142 |
=head1 Who wrote this? |
=head1 Who wrote this? |
143 |
|
|
144 |
Hyper Estraier is written by Mikio Hirabayashi. |
Hyper Estraier is written by Mikio Hirabayashi. |