I am using using below code for searching text for documents using whoosh python library please help me how to get search result if any one use synonym words in query text search. Please help me for search synonyms text search. what line of code i need to add for searching synonyms words are available in text?
from whoosh.qparser import QueryParser
from whoosh import index
ix = index.open_dir("indexdir")
with ix.searcher() as searcher:
query = QueryParser("content", ix.schema).parse("treatment of lung cancer in early stages")
results = searcher.search(query, terms=True)
for r in results:
print(r, r.score)
# Was this results object created with terms=True?
if results.has_matched_terms():
# What terms matched in the results?
print(results.matched_terms())
# What terms matched in each hit?
print("matched terms")
for hit in results:
print(hit.matched_terms())