python
from whoosh.index import create_in
from whoosh.index import LockError
def create_index(directory):
try:
ix = create_in(directory, schema)
except LockError:
except Exception as e:
python
from whoosh.qparser import QueryParser
from whoosh.query import QueryError
def search_index(query_string, ix):
try:
with ix.searcher() as searcher:
query = QueryParser("content", ix.schema).parse(query_string)
results = searcher.search(query)
except QueryError:
except Exception as e: