--- trunk/Estraier.pm 2006/01/28 19:18:13 98 +++ trunk/Estraier.pm 2006/05/08 21:33:37 132 @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.04_1'; +our $VERSION = '0.06_1'; =head1 NAME @@ -17,9 +17,11 @@ use Search::Estraier; # create and configure node - my $node = new Search::Estraier::Node; - $node->set_url("http://localhost:1978/node/test"); - $node->set_auth("admin","admin"); + my $node = new Search::Estraier::Node( + url => 'http://localhost:1978/node/test', + user => 'admin', + passwd => 'admin' + ); # create document my $doc = new Search::Estraier::Document; @@ -32,16 +34,19 @@ $doc->add_text("Somewhere over the rainbow. Way up high."); $doc->add_text("There's a land that I heard of once in a lullaby."); - die "error: ", $node->status,"\n" unless ($node->put_doc($doc)); + die "error: ", $node->status,"\n" unless (eval { $node->put_doc($doc) }); =head2 Simple searcher use Search::Estraier; # create and configure node - my $node = new Search::Estraier::Node; - $node->set_url("http://localhost:1978/node/test"); - $node->set_auth("admin","admin"); + my $node = new Search::Estraier::Node( + url => 'http://localhost:1978/node/test', + user => 'admin', + passwd => 'admin', + croak_on_error => 1, + ); # create condition my $cond = new Search::Estraier::Condition; @@ -50,7 +55,10 @@ $cond->set_phrase("rainbow AND lullaby"); my $nres = $node->search($cond, 0); + if (defined($nres)) { + print "Got ", $nres->hits, " results\n"; + # for each document in results for my $i ( 0 ... $nres->doc_num - 1 ) { # get result document @@ -591,6 +599,35 @@ } +=head2 set_skip + +Set number of skipped documents from beginning of results + + $cond->set_skip(42); + +Similar to C in RDBMS. + +=cut + +sub set_skip { + my $self = shift; + $self->{skip} = shift; +} + +=head2 skip + +Return skip for this condition. + + print $cond->skip; + +=cut + +sub skip { + my $self = shift; + return $self->{skip}; +} + + package Search::Estraier::ResultDocument; use Carp qw/croak/; @@ -734,6 +771,9 @@ print $res->doc_num; +This will return real number of documents (limited by C). +If you want to get total number of hits, see C. + =cut sub doc_num { @@ -765,7 +805,7 @@ Return specific hint from results. - print $rec->hint( 'VERSION' ); + print $res->hint( 'VERSION' ); Possible hints are: C, C, C, C, C, C, C