parseAlgoliaHitReverseSnippet function lets you parse the non-highlighted parts of an Algolia hit’s snippet.
This is a common pattern for Query Suggestions,
where you want to highlight the differences between each suggestion.
If you’re using
autocomplete-js,
all Algolia utilities are available directly in the package with the right user agents and the virtual DOM layer.
You don’t need to import the preset separately.Installation
First, you need to install the preset.JavaScript
script element:
HTML
Examples
With a single string
JavaScript
Example with nested attributes
JavaScript
Parameters
AlgoliaHit
The Algolia hit whose attribute to retrieve the reverse snippet from.
string | string[]
The attribute to retrieve the reverse snippet from.
You can use the array syntax to reference nested attributes.
Returns
ParsedAttribute[]
An array of the parsed attribute’s parts.