197 |
|
|
198 |
my $template_filename = $args->{template} || $self->{template}; |
my $template_filename = $args->{template} || $self->{template}; |
199 |
|
|
200 |
$args->{max} ||= $self->{'hits_for_pager'}; |
$args->{hits_on_page} ||= $self->{'hits_for_pager'}; |
201 |
if (! $args->{max}) { |
if (! $args->{hits_on_page}) { |
202 |
$args->{max} = 100; |
$args->{hits_on_page} = 100; |
203 |
$log->warn("max not set when calling model. Using default of $args->{max}"); |
$log->warn("max not set when calling model. Using default of $args->{hits_on_page}"); |
204 |
} |
} |
205 |
|
|
206 |
my $times; # store some times for benchmarking |
my $times; # store some times for benchmarking |
215 |
} |
} |
216 |
$args->{depth} ||= 0; |
$args->{depth} ||= 0; |
217 |
|
|
218 |
$log->debug("searching " . $self->{est_node}->{url} . " max: $args->{max} depth: $args->{depth} phrase: " . ($query || '[none]') ); |
$log->debug("searching " . $self->{est_node}->{url} . " hits on page: $args->{hits_on_page} depth: $args->{depth} phrase: " . ($query || '[none]') ); |
219 |
|
|
220 |
# |
# |
221 |
# construct condition for Hyper Estraier |
# construct condition for Hyper Estraier |
233 |
$cond->set_options( $args->{options} ) if ($args->{options}); |
$cond->set_options( $args->{options} ) if ($args->{options}); |
234 |
$cond->set_order( $args->{order} ) if ($args->{order}); |
$cond->set_order( $args->{order} ) if ($args->{order}); |
235 |
|
|
236 |
my $max = $args->{max} || 7; |
my $hits_on_page = $args->{hits_on_page} || 7; |
237 |
my $page = $args->{page} || 1; |
my $page = $args->{page} || 1; |
238 |
if ($page < 1) { |
if ($page < 1) { |
239 |
$log->warn("page number $page < 1"); |
$log->warn("page number $page < 1"); |
240 |
$page = 1; |
$page = 1; |
241 |
} |
} |
242 |
|
|
243 |
$cond->set_max( $page * $max ); |
$cond->set_max( my $max = $page * $hits_on_page ); |
244 |
|
$cond->set_skip( my $skip = ( $page - 1 ) * $hits_on_page ); |
245 |
|
|
246 |
|
$log->debug("search max: $max, skip: $skip"); |
247 |
|
|
248 |
my $result = $self->{est_node}->search($cond, $args->{depth}); |
my $result = $self->{est_node}->search($cond, $args->{depth}); |
249 |
if (! $result) { |
if (! $result) { |
265 |
|
|
266 |
my @results; |
my @results; |
267 |
|
|
268 |
for my $i ( (($page - 1) * $max) .. ( $hits - 1 ) ) { |
#for my $i ( (($page - 1) * $max) .. ( $hits - 1 ) ) { |
269 |
|
for my $i ( 0 .. $max ) { |
270 |
|
|
271 |
$t = time(); |
$t = time(); |
272 |
|
|