blob: b9033f3c46e5670e8bd9470c753436fd0979f7b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/python2.6
# coding: utf-8
from whoosh.index import open_dir
from whoosh.qparser import QueryParser
index = open_dir(u"index", mapped=False)
searcher = index.searcher()
while True:
term = raw_input("query> ")
query = QueryParser("content").parse(term)
print query
results = searcher.search(query)
for result in results:
print "Match in {0}".format(result.get("path"))
print "{0} results".format(len(results))
|