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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Sat Sep 3 18:04:41 2005 UTC (16 years, 3 months ago) by dpavlin
File size: 657 byte(s)
make working copy
1 #!/usr/bin/ruby
2 """
3 simplest implementation of a searcher
4 """
5
6 require 'HyperEstraier'
7
8 # open the database
9 db = HyperEstraier::Database.new()
10 db.open('casket', HyperEstraier::Database::DBREADER)
11
12 # create a search condition object
13 cond = HyperEstraier::Condition.new()
14
15 # set the search phrase to the search condition object
16 cond.set_phrase('somewhere')
17
18 # get the result of search
19 result = db.search(cond, 0)
20
21 # for each document in result
22 result.each {|id|
23 # get the document object
24 doc = db.get_doc(id, 0)
25
26 # display attributes
27 puts "URI: #{doc.attr('@uri')}"
28 puts "Title: #{doc.attr('@title')}"
29
30 # display the body text
31 puts doc.cat_texts()
32 }
33

  ViewVC Help
Powered by ViewVC 1.1.26