245 |
|
|
246 |
$log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) ); |
$log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) ); |
247 |
|
|
248 |
$log->dumper($result->{hints}, 'result->hints' ); |
$self->{hints} = $result->{hints}; |
249 |
|
$log->dumper($self->{hints}, 'hints' ); |
250 |
|
|
251 |
# |
# |
252 |
# fetch results |
# fetch results |
331 |
return \@results; |
return \@results; |
332 |
} |
} |
333 |
|
|
334 |
|
=head2 hints |
335 |
|
|
336 |
|
my $hints = $m->hints; |
337 |
|
|
338 |
|
Return various useful hints about result |
339 |
|
|
340 |
|
=cut |
341 |
|
|
342 |
|
sub hints { |
343 |
|
my $self = shift; |
344 |
|
|
345 |
|
unless ($self->{hints}) { |
346 |
|
$self->{log}->fatal("no hints found!"); |
347 |
|
return; |
348 |
|
} |
349 |
|
|
350 |
|
my $hints; |
351 |
|
|
352 |
|
while (my ($key,$val) = each %{ $self->{hints} }) { |
353 |
|
|
354 |
|
if ($key =~ m/^(?:HITS*|TIME|DOCNUM|WORDNUM)$/) { |
355 |
|
$hints->{ lc($key) } = $val; |
356 |
|
} elsif ($key =~ m/^HINT#/) { |
357 |
|
my ($word,$count) = split(/\t/,$val,2); |
358 |
|
$hints->{words}->{$word} = $count; |
359 |
|
} elsif ($key =~ m/^LINK#/) { |
360 |
|
my ($url,undef,undef,undef,undef,undef,$results) = split(/\t/,$val,7); |
361 |
|
if ($url =~ m#/node/(.+)$#) { |
362 |
|
$hints->{node}->{$1} = $results; |
363 |
|
} |
364 |
|
} |
365 |
|
} |
366 |
|
|
367 |
|
return $hints; |
368 |
|
} |
369 |
|
|
370 |
|
|
371 |
=head2 record |
=head2 record |
372 |
|
|
373 |
my $html = $m->record( |
my $html = $m->record( |
419 |
} |
} |
420 |
|
|
421 |
|
|
422 |
|
=head2 list_nodes |
423 |
|
|
424 |
|
my @nodes = $m->list_nodes( 'site' ); |
425 |
|
|
426 |
|
Return all databases which have records for selected site. Returned array of |
427 |
|
hashes has elements C<name> and C<label>. |
428 |
|
|
429 |
|
=cut |
430 |
|
|
431 |
|
sub list_nodes { |
432 |
|
my $self = shift; |
433 |
|
|
434 |
|
my $site = shift; |
435 |
|
|
436 |
|
$self->{log}->debug("list_nodes use site $site"); |
437 |
|
|
438 |
|
$self->setup_site( $site ); |
439 |
|
|
440 |
|
my @nodes; |
441 |
|
|
442 |
|
if ($self->{est_node}->doc_num > 0) { |
443 |
|
push @nodes, { |
444 |
|
name => $self->{est_node}->name, |
445 |
|
label => $self->{est_node}->label, |
446 |
|
doc_num => $self->{est_node}->doc_num, |
447 |
|
} |
448 |
|
} |
449 |
|
|
450 |
|
# refresh set info |
451 |
|
$self->{est_node}->_set_info; |
452 |
|
|
453 |
|
my $links = $self->{est_node}->links || return @nodes; |
454 |
|
|
455 |
|
$self->{log}->dumper( $links, 'links' ); |
456 |
|
|
457 |
|
foreach my $link (@{ $links }) { |
458 |
|
my ($url, $label, $credit) = split(/\t/, $link, 3); |
459 |
|
if ($url =~ m#/node/(.+)$#) { |
460 |
|
my $node = $1; |
461 |
|
$self->setup_site( $node ); |
462 |
|
$self->{est_node}->_set_info; |
463 |
|
push @nodes, { |
464 |
|
name => $node, |
465 |
|
label => $label, |
466 |
|
doc_num => $self->{est_node}->doc_num, |
467 |
|
} |
468 |
|
} else { |
469 |
|
$self->{log}->warn("can't find node name in link $link"); |
470 |
|
} |
471 |
|
} |
472 |
|
|
473 |
|
$self->setup_site( $site ); |
474 |
|
$self->{est_node}->_set_info; |
475 |
|
|
476 |
|
$self->{log}->dumper( \@nodes, 'nodes' ); |
477 |
|
|
478 |
|
return @nodes; |
479 |
|
} |
480 |
|
|
481 |
|
=cut |
482 |
|
|
483 |
|
|
484 |
=head2 save_html |
=head2 save_html |
485 |
|
|
486 |
$m->save_html( '/full/path/to/file', $content ); |
$m->save_html( '/full/path/to/file', $content ); |