/[hyperestraier_wrappers]/trunk/examples/nodesearch.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/examples/nodesearch.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Thu Sep 8 22:51:10 2005 UTC (18 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 799 byte(s)
rename NodeDocument to ResultDocument (it was really mis-named),
fixed condition in NodeRes, move est_noderes_get_doc to NodeRes
class (so that NodeDocument resambles more Document class),
added (working :-) example of node search

1 #!/usr/bin/env perl
2 # simplest implementation of a node searcher
3
4 use strict;
5 use warnings;
6
7 use HyperEstraier;
8
9 # open the database
10 my $node = HyperEstraier::Node->new("http://localhost:1978/node/test1");
11 $node->set_auth('admin', 'admin');
12
13 # create a search condition object
14 my $cond = HyperEstraier::Condition->new();
15
16 # set the search phrase to the search condition object
17 $cond->set_phrase('somewhere');
18
19 # get the result of search
20 my $result = $node->search($cond, 0);
21
22 print "found ", $result->doc_num, " results\n";
23
24 # for each document in result
25 for my $i (0 .. $result->doc_num-1) {
26 my $ndoc = $result->get_doc($i);
27 # display attributes
28 printf "URI: %s\n", $ndoc->attr('@uri');
29 printf "Title: %s\n", $ndoc->attr('@title');
30
31 # display the snippet text
32 print $ndoc->snippet(), "\n";
33 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26