highlight method
Leave feedback
On this page
Generates HTML formatted text with highlighted found terms.
Search results in the search network can be highlighted in the text of the found document using this method. The found document is passed as a NetworkFoundDocument object obtained from a search result.
def highlight(self, document, highlighter, options):
...
| Parameter | Type | Description |
|---|---|---|
| document | NetworkFoundDocument |
The found document. |
| highlighter | Highlighter |
The search result highlighter. |
| options | HighlightOptions |
The highlight options. |
Returns: None.
import os
from groupdocs.search import Index
from groupdocs.search.common import FileOutputAdapter
from groupdocs.search.highlighters import DocumentHighlighter
from groupdocs.search.options import OutputFormat
os.makedirs("./output", exist_ok=True)
with Index("./index") as index:
index.add("./documents")
result = index.search("Einstein")
if result.document_count > 0:
adapter = FileOutputAdapter(OutputFormat.HTML, "./output/Highlighted.html")
highlighter = DocumentHighlighter(adapter)
index.highlight(result.get_found_document(0), highlighter)
print("Written: ./output/Highlighted.html")
These names call highlight too, limited to the overloads listed.
| Alias | Accepts |
|---|---|
highlight_network_found_document |
highlight_network_found_document(document, highlighter, options) |
- class
Searcher
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.