Parent: [4c7586] (diff)

Child: [b0e296] (diff)

Download this file

recollqsd.py    36 lines (29 with data), 954 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
#!/usr/bin/env python
"""Example for using the ''searchdata''' structured query interface.
Not good for anything except showing/trying the code."""
import sys
import recoll
def dotest(db, q):
query = db.query()
query.sortby("title", 1)
nres = query.executesd(q)
print "Result count: ", nres
if nres > 10:
nres = 10
for i in range(nres):
doc = query.fetchone()
print query.next if type(query.next) == int else query.rownumber
for k in ("url", "mtime", "title", "author", "abstract"):
print k, ":", getattr(doc, k).encode('utf-8')
#abs = db.makeDocAbstract(doc, query).encode('utf-8')
#print abs
print
# End dotest
sd = recoll.SearchData()
sd.addclause("and", "essaouira maroc")
#sd.addclause("and", "dockes", field="author")
#sd.addclause("phrase", "jean francois", 1)
#sd.addclause("excl", "plage")
db = recoll.connect()
dotest(db, sd)
sys.exit(0)