50 |
$cond->set_phrase("rainbow AND lullaby"); |
$cond->set_phrase("rainbow AND lullaby"); |
51 |
|
|
52 |
my $nres = $node->search($cond, 0); |
my $nres = $node->search($cond, 0); |
53 |
|
print "Got ", $nres->hits, " results\n"; |
54 |
|
|
55 |
if (defined($nres)) { |
if (defined($nres)) { |
56 |
# for each document in results |
# for each document in results |
57 |
for my $i ( 0 ... $nres->doc_num - 1 ) { |
for my $i ( 0 ... $nres->doc_num - 1 ) { |
736 |
|
|
737 |
print $res->doc_num; |
print $res->doc_num; |
738 |
|
|
739 |
|
This will return real number of documents (limited by C<max>). |
740 |
|
If you want to get total number of hits, see C<hits>. |
741 |
|
|
742 |
=cut |
=cut |
743 |
|
|
744 |
sub doc_num { |
sub doc_num { |
770 |
|
|
771 |
Return specific hint from results. |
Return specific hint from results. |
772 |
|
|
773 |
print $rec->hint( 'VERSION' ); |
print $res->hint( 'VERSION' ); |
774 |
|
|
775 |
Possible hints are: C<VERSION>, C<NODE>, C<HIT>, C<HINT#n>, C<DOCNUM>, C<WORDNUM>, |
Possible hints are: C<VERSION>, C<NODE>, C<HIT>, C<HINT#n>, C<DOCNUM>, C<WORDNUM>, |
776 |
C<TIME>, C<LINK#n>, C<VIEW>. |
C<TIME>, C<LINK#n>, C<VIEW>. |
783 |
return $self->{hints}->{$key}; |
return $self->{hints}->{$key}; |
784 |
} |
} |
785 |
|
|
786 |
=head2 hints |
=head2 hits |
787 |
|
|
788 |
More perlish version of C<hint>. This one returns hash. |
More perlish version of C<hint>. This one returns hash. |
789 |
|
|
790 |
my %hints = $rec->hints; |
my %hints = $res->hints; |
791 |
|
|
792 |
=cut |
=cut |
793 |
|
|
796 |
return $self->{hints}; |
return $self->{hints}; |
797 |
} |
} |
798 |
|
|
799 |
|
=head2 hits |
800 |
|
|
801 |
|
Syntaxtic sugar for total number of hits for this query |
802 |
|
|
803 |
|
print $res->hits; |
804 |
|
|
805 |
|
It's same as |
806 |
|
|
807 |
|
print $res->hint('HIT'); |
808 |
|
|
809 |
|
but shorter. |
810 |
|
|
811 |
|
=cut |
812 |
|
|
813 |
|
sub hits { |
814 |
|
my $self = shift; |
815 |
|
return $self->{hints}->{'HIT'} || 0; |
816 |
|
} |
817 |
|
|
818 |
package Search::Estraier::Node; |
package Search::Estraier::Node; |
819 |
|
|
820 |
use Carp qw/carp croak confess/; |
use Carp qw/carp croak confess/; |