/[hyperestraier_wrappers]/trunk/examples/search.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/search.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Sat Sep 3 18:04:41 2005 UTC (18 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 765 byte(s)
make working copy
1 #!/usr/bin/env perl
2 # simplest implementation of a searcher
3
4 use strict;
5 use Data::Dumper;
6
7 use HyperEstraier;
8
9 # open the database
10 my $db = HyperEstraier::Database->new();
11 $db->open('casket', $HyperEstraier::ESTDBREADER);
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 = $db->search($cond, 0);
21 $result->get(0);
22
23 # for each document in result
24 for my $i (0..$result->size-1) {
25 my $id = $result->get($i);
26 my $doc = $db->get_doc($id, 0);
27 # display attributes
28 printf "URI: %s\n", $doc->attr('@uri');
29 printf "Title: %s\n", $doc->attr('@title');
30
31 # display the body text
32 print $doc->cat_texts(), "\n";
33 }

  ViewVC Help
Powered by ViewVC 1.1.26