13 lines
296 B
Python
13 lines
296 B
Python
|
from whoosh import index, qparser
|
||
|
|
||
|
_index = index.open_dir("_index")
|
||
|
parser = qparser.QueryParser("text",_index.schema)
|
||
|
|
||
|
def search(q):
|
||
|
q = parser.parse(q)
|
||
|
out = []
|
||
|
with _index.searcher() as s:
|
||
|
for result in s.search(q,limit=None):
|
||
|
out.append((result["title"],result["url"]))
|
||
|
return out
|