/[hyperestraier_wrappers]/0.0.12/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

Annotation of /0.0.12/examples/search.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Sat Sep 3 18:02:31 2005 UTC (18 years, 7 months ago) by dpavlin
File size: 657 byte(s)
import of hyper_estraier_wrappers-0.0.12.tar.gz

1 dpavlin 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