def query(qstr, limit=10):
    index_dir = os.path.join(__opts__['cachedir'], 'whoosh')
    if whoosh.index.exists_in(index_dir):
        ix_ = whoosh.index.open_dir(index_dir)
    else:
        return {}
    qp_ = whoosh.qparser.QueryParser(u'content', schema=ix_.schema)
    qobj = qp_.parse(six.text_type(qstr), limit)
    with ix_.searcher() as searcher:
        return searcher.search(qobj)
Execute a query
dataset/ETHPy150Open saltstack/salt/salt/search/whoosh_search.py/query