4 |
use strict; |
use strict; |
5 |
use warnings; |
use warnings; |
6 |
|
|
7 |
our $VERSION = '0.08'; |
our $VERSION = '0.07_3'; |
8 |
|
|
9 |
=head1 NAME |
=head1 NAME |
10 |
|
|
120 |
|
|
121 |
=head1 Search::Estraier::Document |
=head1 Search::Estraier::Document |
122 |
|
|
123 |
This class implements Document which is collection of attributes |
This class implements Document which is single item in Hyper Estraier. |
|
(key=value), vectors (also key value) display text and hidden text. |
|
124 |
|
|
125 |
|
It's is collection of: |
126 |
|
|
127 |
|
=over 4 |
128 |
|
|
129 |
|
=item attributes |
130 |
|
|
131 |
|
C<< 'key' => 'value' >> pairs which can later be used for filtering of results |
132 |
|
|
133 |
|
You can add common filters to C<attrindex> in estmaster's C<_conf> |
134 |
|
file for better performance. See C<attrindex> in |
135 |
|
L<Hyper Estraier P2P Guide|http://hyperestraier.sourceforge.net/nguide-en.html>. |
136 |
|
|
137 |
|
=item vectors |
138 |
|
|
139 |
|
also C<< 'key' => 'value' >> pairs |
140 |
|
|
141 |
|
=item display text |
142 |
|
|
143 |
|
Text which will be used to create searchable corpus of your index and |
144 |
|
included in snippet output. |
145 |
|
|
146 |
|
=item hidden text |
147 |
|
|
148 |
|
Text which will be searchable, but will not be included in snippet. |
149 |
|
|
150 |
|
=back |
151 |
|
|
152 |
=head2 new |
=head2 new |
153 |
|
|
182 |
|
|
183 |
if ($line =~ m/^%VECTOR\t(.+)$/) { |
if ($line =~ m/^%VECTOR\t(.+)$/) { |
184 |
my @fields = split(/\t/, $1); |
my @fields = split(/\t/, $1); |
185 |
for my $i ( 0 .. ($#fields - 1) ) { |
if ($#fields % 2 == 1) { |
186 |
$self->{kwords}->{ $fields[ $i ] } = $fields[ $i + 1 ]; |
$self->{kwords} = { @fields }; |
187 |
$i++; |
} else { |
188 |
|
warn "can't decode $line\n"; |
189 |
} |
} |
190 |
next; |
next; |
191 |
} elsif ($line =~ m/^%/) { |
} elsif ($line =~ m/^%/) { |
269 |
push @{ $self->{htexts} }, $self->_s($text); |
push @{ $self->{htexts} }, $self->_s($text); |
270 |
} |
} |
271 |
|
|
272 |
|
=head2 add_vectors |
273 |
|
|
274 |
|
Add a vectors |
275 |
|
|
276 |
|
$doc->add_vector( |
277 |
|
'vector_name' => 42, |
278 |
|
'another' => 12345, |
279 |
|
); |
280 |
|
|
281 |
|
=cut |
282 |
|
|
283 |
|
sub add_vectors { |
284 |
|
my $self = shift; |
285 |
|
return unless (@_); |
286 |
|
|
287 |
|
# this is ugly, but works |
288 |
|
die "add_vector needs HASH as argument" unless ($#_ % 2 == 1); |
289 |
|
|
290 |
|
$self->{kwords} = {@_}; |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
=head2 id |
=head2 id |
295 |
|
|
384 |
} |
} |
385 |
|
|
386 |
if ($self->{kwords}) { |
if ($self->{kwords}) { |
387 |
$draft .= '%%VECTOR'; |
$draft .= '%VECTOR'; |
388 |
while (my ($key, $value) = each %{ $self->{kwords} }) { |
while (my ($key, $value) = each %{ $self->{kwords} }) { |
389 |
$draft .= "\t$key\t$value"; |
$draft .= "\t$key\t$value"; |
390 |
} |
} |
1353 |
$path = '/etch_doc' if ($a->{etch}); |
$path = '/etch_doc' if ($a->{etch}); |
1354 |
|
|
1355 |
if ($a->{id}) { |
if ($a->{id}) { |
1356 |
croak "id must be numberm not '$a->{id}'" unless ($a->{id} =~ m/^\d+$/); |
croak "id must be number not '$a->{id}'" unless ($a->{id} =~ m/^\d+$/); |
1357 |
$arg = 'id=' . $a->{id}; |
$arg = 'id=' . $a->{id}; |
1358 |
} elsif ($a->{uri}) { |
} elsif ($a->{uri}) { |
1359 |
$arg = 'uri=' . uri_escape($a->{uri}); |
$arg = 'uri=' . uri_escape($a->{uri}); |
1562 |
push @args, 'wwidth=' . $self->{wwidth}; |
push @args, 'wwidth=' . $self->{wwidth}; |
1563 |
push @args, 'hwidth=' . $self->{hwidth}; |
push @args, 'hwidth=' . $self->{hwidth}; |
1564 |
push @args, 'awidth=' . $self->{awidth}; |
push @args, 'awidth=' . $self->{awidth}; |
1565 |
push @args, 'skip=' . $self->{skip} if ($self->{skip}); |
push @args, 'skip=' . $cond->{skip} if ($cond->{skip}); |
1566 |
|
|
1567 |
return join('&', @args); |
return join('&', @args); |
1568 |
} |
} |
1790 |
return $self->{inform}->{links}; |
return $self->{inform}->{links}; |
1791 |
} |
} |
1792 |
|
|
1793 |
|
=head2 cacheusage |
1794 |
|
|
1795 |
|
Return cache usage for a node |
1796 |
|
|
1797 |
|
my $cache = $node->cacheusage; |
1798 |
|
|
1799 |
|
=cut |
1800 |
|
|
1801 |
|
sub cacheusage { |
1802 |
|
my $self = shift; |
1803 |
|
|
1804 |
|
return unless ($self->{url}); |
1805 |
|
|
1806 |
|
my $resbody; |
1807 |
|
my $rv = $self->shuttle_url( $self->{url} . '/cacheusage', |
1808 |
|
'text/plain', |
1809 |
|
undef, |
1810 |
|
\$resbody, |
1811 |
|
); |
1812 |
|
|
1813 |
|
return if ($rv != 200 || !$resbody); |
1814 |
|
|
1815 |
|
return $resbody; |
1816 |
|
} |
1817 |
|
|
1818 |
=head2 master |
=head2 master |
1819 |
|
|
1820 |
Set actions on Hyper Estraier node master (C<estmaster> process) |
Set actions on Hyper Estraier node master (C<estmaster> process) |
2034 |
|
|
2035 |
Hyper Estraier Ruby interface on which this module is based. |
Hyper Estraier Ruby interface on which this module is based. |
2036 |
|
|
2037 |
|
Hyper Estraier now also has pure-perl binding included in distribution. It's |
2038 |
|
a faster way to access databases directly if you are not running |
2039 |
|
C<estmaster> P2P server. |
2040 |
|
|
2041 |
=head1 AUTHOR |
=head1 AUTHOR |
2042 |
|
|
2043 |
Dobrica Pavlinusic, E<lt>dpavlin@rot13.orgE<gt> |
Dobrica Pavlinusic, E<lt>dpavlin@rot13.orgE<gt> |