580 |
} |
} |
581 |
|
|
582 |
|
|
583 |
|
package Search::Estraier::NodeResult; |
584 |
|
|
585 |
|
use Carp qw/croak/; |
586 |
|
|
587 |
|
#use Search::Estraier; |
588 |
|
#our @ISA = qw/Search::Estraier/; |
589 |
|
|
590 |
|
=head1 Search::Estraier::NodeResult |
591 |
|
|
592 |
|
=head2 new |
593 |
|
|
594 |
|
my $res = new Search::HyperEstraier::NodeResult( |
595 |
|
docs => @array_of_rdocs, |
596 |
|
hits => %hash_with_hints, |
597 |
|
); |
598 |
|
|
599 |
|
=cut |
600 |
|
|
601 |
|
sub new { |
602 |
|
my $class = shift; |
603 |
|
my $self = {@_}; |
604 |
|
bless($self, $class); |
605 |
|
|
606 |
|
foreach my $f (qw/docs hints/) { |
607 |
|
croak "missing $f for ResultDocument" unless defined($self->{$f}); |
608 |
|
} |
609 |
|
|
610 |
|
$self ? return $self : return undef; |
611 |
|
} |
612 |
|
|
613 |
|
=head2 doc_num |
614 |
|
|
615 |
|
Return number of documents |
616 |
|
|
617 |
|
print $res->doc_num; |
618 |
|
|
619 |
|
=cut |
620 |
|
|
621 |
|
sub doc_num { |
622 |
|
my $self = shift; |
623 |
|
return $#{$self->{docs}}; |
624 |
|
} |
625 |
|
|
626 |
|
=head2 get_doc |
627 |
|
|
628 |
|
Return single document |
629 |
|
|
630 |
|
my $doc = $res->get_doc( 42 ); |
631 |
|
|
632 |
|
Returns undef if document doesn't exist. |
633 |
|
|
634 |
|
=cut |
635 |
|
|
636 |
|
sub get_doc { |
637 |
|
my $self = shift; |
638 |
|
my $num = shift; |
639 |
|
croak "expect number as argument" unless ($num =~ m/^\d+$/); |
640 |
|
return undef if ($num < 0 || $num > $self->{docs}); |
641 |
|
return $self->{docs}->[$num]; |
642 |
|
} |
643 |
|
|
644 |
|
=head2 hint |
645 |
|
|
646 |
|
Return specific hint from results. |
647 |
|
|
648 |
|
print $rec->hint( 'VERSION' ); |
649 |
|
|
650 |
|
Possible hints are: C<VERSION>, C<NODE>, C<HIT>, C<HINT#n>, C<DOCNUM>, C<WORDNUM>, |
651 |
|
C<TIME>, C<LINK#n>, C<VIEW>. |
652 |
|
|
653 |
|
=cut |
654 |
|
|
655 |
|
sub hint { |
656 |
|
my $self = shift; |
657 |
|
my $key = shift || return; |
658 |
|
return $self->{hints}->{$key}; |
659 |
|
} |
660 |
|
|
661 |
|
|
662 |
|
package Search::Estraier::Node; |
663 |
|
|
664 |
|
use Carp qw/croak/; |
665 |
|
|
666 |
|
=head1 Search::Estraier::Node |
667 |
|
|
668 |
|
=head2 new |
669 |
|
|
670 |
|
my $node = new Search::HyperEstraier::Node; |
671 |
|
|
672 |
|
=cut |
673 |
|
|
674 |
|
sub new { |
675 |
|
my $class = shift; |
676 |
|
my $self = { |
677 |
|
pxport => -1, |
678 |
|
timeout => -1, |
679 |
|
dnum => -1, |
680 |
|
wnum => -1, |
681 |
|
size => -1.0, |
682 |
|
wwidth => 480, |
683 |
|
hwidth => 96, |
684 |
|
awidth => 96, |
685 |
|
status => -1, |
686 |
|
}; |
687 |
|
bless($self, $class); |
688 |
|
|
689 |
|
$self ? return $self : return undef; |
690 |
|
} |
691 |
|
|
692 |
|
=head2 set_url |
693 |
|
|
694 |
|
Specify URL to node server |
695 |
|
|
696 |
|
$node->set_url('http://localhost:1978'); |
697 |
|
|
698 |
|
=cut |
699 |
|
|
700 |
|
sub set_url { |
701 |
|
my $self = shift; |
702 |
|
$self->{url} = shift; |
703 |
|
} |
704 |
|
|
705 |
|
=head2 set_proxy |
706 |
|
|
707 |
|
Specify proxy server to connect to node server |
708 |
|
|
709 |
|
$node->set_proxy('proxy.example.com', 8080); |
710 |
|
|
711 |
|
=cut |
712 |
|
|
713 |
|
sub set_proxy { |
714 |
|
my $self = shift; |
715 |
|
my ($host,$port) = @_; |
716 |
|
croak "proxy port must be number" unless ($port =~ m/^\d+$/); |
717 |
|
$self->{pxhost} = $host; |
718 |
|
$self->{pxport} = $port; |
719 |
|
} |
720 |
|
|
721 |
package Search::Estraier::Master; |
package Search::Estraier::Master; |
722 |
|
|
723 |
use Carp; |
use Carp; |