--- trunk/Estraier.pm 2006/01/07 23:48:16 65 +++ trunk/Estraier.pm 2006/01/08 00:13:09 68 @@ -12,8 +12,57 @@ =head1 SYNOPSIS - use Search::Estraier; - my $est = new Search::Estraier(); +=head2 Simple indexer + + 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"); + + # create document + my $doc = new Search::Estraier::Document; + + # add attributes + $doc->add_attr('@uri', "http://estraier.gov/example.txt"); + $doc->add_attr('@title', "Over the Rainbow"); + + # add body text to document + $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)); + +=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"); + + # create condition + my $cond = new Search::Estraier::Condition; + + # set search phrase + $cond->set_phrase("rainbow AND lullaby"); + + my $nres = $node->search($cond, 0); + if (defined($nres)) { + # for each document in results + for my $i ( 0 ... $nres->doc_num - 1 ) { + # get result document + my $rdoc = $nres->get_doc($i); + # display attribte + print "URI: ", $rdoc->attr('@uri'),"\n"; + print "Title: ", $rdoc->attr('@title'),"\n"; + print $rdoc->snippet,"\n"; + } + } else { + die "error: ", $node->status,"\n"; + } =head1 DESCRIPTION @@ -25,6 +74,8 @@ It is implemented as multiple packages which closly resamble Ruby implementation. It also includes methods to manage nodes. +There are few examples in C directory of this distribution. + =cut =head1 Inheritable common methods @@ -1325,7 +1376,7 @@ =head2 shuttle_url -This is method which uses C to communicate with Hyper Estraier node +This is method which uses C to communicate with Hyper Estraier node master. my $rv = shuttle_url( $url, $content_type, $req_body, \$resbody );