13 |
|
|
14 |
=head1 VERSION |
=head1 VERSION |
15 |
|
|
16 |
Version 0.02 |
Version 0.03 |
17 |
|
|
18 |
=cut |
=cut |
19 |
|
|
20 |
our $VERSION = '0.02'; |
our $VERSION = '0.03'; |
21 |
|
|
22 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
23 |
|
|
109 |
order => 'NUMD', |
order => 'NUMD', |
110 |
max => 100, |
max => 100, |
111 |
options => $HyperEstraier::Condition::SURE, |
options => $HyperEstraier::Condition::SURE, |
112 |
|
page => 42, |
113 |
); |
); |
114 |
|
|
115 |
Options are close match to Hyper Estraier API, except C<get_attr> which defines |
Options are close match to Hyper Estraier API, except C<get_attr> which defines |
117 |
|
|
118 |
Results are returned as hash array with keys named by attributes |
Results are returned as hash array with keys named by attributes |
119 |
|
|
120 |
|
Pages are numbered C< 1 ... hits/max >. |
121 |
|
|
122 |
=cut |
=cut |
123 |
|
|
124 |
sub search { |
sub search { |
149 |
}; |
}; |
150 |
|
|
151 |
$cond->set_phrase( $self->{iconv}->convert($q) ) if ($q); |
$cond->set_phrase( $self->{iconv}->convert($q) ) if ($q); |
|
$cond->set_max( $args->{max} ) if ($args->{max}); |
|
152 |
$cond->set_options( $args->{options} ) if ($args->{options}); |
$cond->set_options( $args->{options} ) if ($args->{options}); |
153 |
$cond->set_order( $args->{order} ) if ($args->{order}); |
$cond->set_order( $args->{order} ) if ($args->{order}); |
154 |
|
|
155 |
|
my $max = $args->{max} || 7; |
156 |
|
my $page = $args->{page} || 1; |
157 |
|
|
158 |
|
$cond->set_max( $page * $max ); |
159 |
|
|
160 |
my $result = $self->{db}->search($cond, 0) || |
my $result = $self->{db}->search($cond, 0) || |
161 |
$log->die("can't search for ", sub { Dumper( $args ) }); |
$log->die("can't search for ", sub { Dumper( $args ) }); |
162 |
|
|
165 |
|
|
166 |
my @results; |
my @results; |
167 |
|
|
168 |
for my $i ( 0 .. ( $hits - 1 ) ) { |
for my $i ( (($page - 1) * $max) .. ( $hits - 1 ) ) { |
169 |
|
|
170 |
#$log->debug("get_doc($i)"); |
#$log->debug("get_doc($i)"); |
171 |
my $doc = $result->get_doc( $i ); |
my $doc = $result->get_doc( $i ); |