Parent: [275846] (diff)

Download this file

simple.py    41 lines (31 with data), 774 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
from recoll import recoll
if sys.version_info[0] >= 3:
ISP3 = True
else:
ISP3 = False
def utf8string(s):
if s is None:
return "None"
if ISP3:
return s
else:
return s.encode('utf8')
db = recoll.connect()
query = db.query()
nres = query.execute("huniique", stemlang="english")
qs = "Xapian query: [%s]" % query.getxquery()
print(utf8string(qs))
print("Result count: %d %d" % (nres, query.rowcount))
print("for i in range(nres):")
for i in range(nres):
doc = query.fetchone()
print(utf8string(doc.filename))
query.scroll(0, 'absolute')
print("\nfor doc in query:")
for doc in query:
print(utf8string(doc.filename))
try:
query.scroll(0, 'badmode')
except:
print("\nCatched bad mode. (ok)")