/[hyperestraier_wrappers]/0.0.13/examples/search.py
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 /0.0.13/examples/search.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (show annotations)
Fri Sep 9 15:26:39 2005 UTC (16 years, 1 month ago) by dpavlin
File MIME type: text/x-python
File size: 1045 byte(s)
import of 0.0.13
1 #!/usr/bin/env python
2 # vim: fileencoding=utf-8
3 """
4 simplest implementation of a searcher
5 """
6
7 import HyperEstraier
8
9 # open the database
10 db = HyperEstraier.Database()
11 db.open('casket', HyperEstraier.Database.DBREADER)
12
13 # create a search condition object
14 cond = HyperEstraier.Condition()
15
16 # set the search phrase to the search condition object
17 cond.set_phrase('somewhere')
18
19 # get the result of search
20 result = db.search(cond, 0)
21
22 # for each document in result
23 <<<<<<< search.py
24 doc = result.next()
25 while doc:
26 print doc.get_id()
27 =======
28 for i in result:
29 print "id = ", i
30 # get the document
31 doc = db.get_doc(i, 0)
32
33 >>>>>>> 1.10
34 # display attributes
35 for attr_name in doc.attr_names():
36 print "%s : %s" % (attr_name, doc.attr(attr_name))
37
38 # display the body text
39 print doc.cat_texts()
40
41 # etch
42 for key, val in db.etch_doc(doc, 10).items():
43 print "%s : %s" % (key, val)
44
45 sv = HyperEstraier.StrVector()
46 sv.push_back('somewhere')
47 sv.push_back('rainbow')
48
49 print doc.make_snippet(sv, 100, 100, 100)
50
51 sv.pop_back()
52 sv.push_back('health')

  ViewVC Help
Powered by ViewVC 1.1.26