pip install whoosh
python
from whoosh.index import create_in
from whoosh.fields import *
schema = Schema(title=TEXT(stored=True), content=TEXT)
index_dir = "my_index_directory"
ix = create_in(index_dir, schema)
writer = ix.writer()
writer.commit()
from whoosh.qparser import QueryParser
searcher = ix.searcher()
results = searcher.search(query)
for result in results:
print(result["title"])