From the Whoosh documentation I can get matched search terms with some context with:
results = mysearcher.search(myquery)
for hit in results:
print(hit["title"])
# Assume "content" field is stored
print(hit.highlights("content"))
I'd like to access the "highlights" as a list of separated items (so that I can enumerate them in a html list) but the output of hit.highlights()
appears to be of type <class 'str'>
, and it's not clear to me that there's a unique delimiter.
Is there a way I can get a list instead of everything concatenated into one string?