169 |
|
|
170 |
my $query = $args->{phrase} || $log->warn("no query phrase") && return; |
my $query = $args->{phrase} || $log->warn("no query phrase") && return; |
171 |
|
|
|
$log->debug("search model query: '$query'"); |
|
|
if ($args->{add_attr}) { |
|
|
$log->debug(" + add_attr: " . |
|
|
join("','", @{ $args->{add_attr} }) |
|
|
); |
|
|
} |
|
|
|
|
172 |
my $template_filename = $args->{template} || $self->{template}; |
my $template_filename = $args->{template} || $self->{template}; |
173 |
|
|
174 |
$args->{max} ||= $self->{'hits_for_pager'}; |
$args->{max} ||= $self->{'hits_for_pager'}; |
187 |
$args->{depth} = $default; |
$args->{depth} = $default; |
188 |
$log->warn("using default search depth $default"); |
$log->warn("using default search depth $default"); |
189 |
} |
} |
190 |
|
$args->{depth} ||= 0; |
191 |
|
|
192 |
$log->debug("searching for maximum $args->{max} results using depth $args->{depth}"); |
$log->debug("searching for maximum $args->{max} results using depth $args->{depth} phrase: ", $query || '[none]'); |
193 |
|
|
194 |
# |
# |
195 |
# construct condition for Hyper Estraier |
# construct condition for Hyper Estraier |
198 |
if ( ref($args->{add_attr}) eq 'ARRAY' ) { |
if ( ref($args->{add_attr}) eq 'ARRAY' ) { |
199 |
$log->debug("adding search attributes: " . join(", ", @{ $args->{add_attr} }) ); |
$log->debug("adding search attributes: " . join(", ", @{ $args->{add_attr} }) ); |
200 |
map { |
map { |
201 |
$cond->add_attr( _convert( $_ ) ); |
$cond->add_attr( $_ ); |
202 |
$log->debug(" + $_"); |
$log->debug(" + $_"); |
203 |
} @{ $args->{add_attr} }; |
} @{ $args->{add_attr} }; |
204 |
}; |
}; |
218 |
|
|
219 |
$cond->set_max( $page * $max ); |
$cond->set_max( $page * $max ); |
220 |
|
|
221 |
my $result = $self->{est_node}->search($cond, ( $args->{depth} || 0 )); |
my $result = $self->{est_node}->search($cond, $args->{depth}); |
222 |
my $hits = $result->doc_num; |
my $hits = $result->doc_num; |
223 |
|
|
224 |
$log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) ); |
$log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) ); |
300 |
|
|
301 |
} |
} |
302 |
|
|
303 |
$log->debug( '@results = ' . Dumper( \@results ) ); |
#$log->debug( '@results = ' . Dumper( \@results ) ); |
304 |
|
|
305 |
$log->debug( sprintf( |
$log->debug( sprintf( |
306 |
"duration breakdown: estraier %.6fs, hash %.6fs, store %.6fs, apply %.6fs, decode %.06f, total: %.6fs", |
"duration breakdown: estraier %.6fs, hash %.6fs, store %.6fs, apply %.6fs, decode %.06f, total: %.6fs", |
549 |
|
|
550 |
my $s; |
my $s; |
551 |
if ($s_el > 0) { |
if ($s_el > 0) { |
552 |
$s = $item->{'search'}->[$i] || die "can't find value $i for type search in field $search"; |
$s = $item->{'search'}->[$i] or warn "can't find value $i for type search in field $search"; |
553 |
} else { |
} else { |
554 |
$s = $item->{'search'}->[0]; |
$s = $item->{'search'}->[0]; |
555 |
} |
} |
556 |
#$s =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg; |
#$s =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg; |
557 |
$s = __quotemeta( $s ); |
$s = __quotemeta( $s ); |
558 |
|
|
559 |
my $d = $item->{'display'}->[$i] || die "can't find value $i for type display in field $display"; |
my $d = $item->{'display'}->[$i] or warn "can't find value $i for type display in field $display"; |
560 |
|
|
561 |
my $template_arg = ''; |
my $template_arg = ''; |
562 |
$template_arg = qq{,'$template'} if ($template); |
$template_arg = qq{,'$template'} if ($template); |