About this widget
Displays the highlighted attributes of your search results.Examples
Consider a movies index. Each movie record consists of two fields:title and year.
Algolia’s response to the query “red” could look like:
JSON
_highlightResult’s value: "The Shawshank <em>Red</em>emption".
The part of the string to highlight is marked with <em> tags or your custom tags.
HighlightedString is constructed with a raw tagged string, detects the tags and creates a TaggedString. This tagged string provides following properties:
input. The input string.output. The input string without its tags.taggedRanges. A list of ranges defining highlighted ranges inoutput.
NSAttributedString.
InstantSearch provides HighlightedString and NSAttributedString extensions to make this easy.
Swift
NSAttributedString can be assigned to a UIKit component that supports it.
Swift
Hit wrapper structure uses the HighlightedString structure.
You can extract a highlighted string for an attribute using its hightlightedString(forKey key: String) function.
Example:
Swift
Hit wrapper structure in the Hits reference.