Highlighting matched terms
UseattributesToHighlight to specify which fields should have matched terms wrapped in highlight tags. Set it to ["*"] to highlight all displayed attributes.
_formatted object in each hit. Inside _formatted, matched terms are wrapped in <em> tags by default:
Custom highlight tags
UsehighlightPreTag and highlightPostTag to replace the default <em> tags with custom markup:
Cropping long text fields
UseattributesToCrop to trim long text fields so only the portion around matched terms is returned. This is especially useful for fields like descriptions or article bodies.
_formatted object contains the cropped text:
Crop parameters
Custom crop length per attribute
You can set a specific crop length for individual attributes by appending:length to the attribute name:
Combining highlighting and cropping
For the best user experience, use both features together. This gives you a short, relevant snippet with matched terms visually emphasized:_formatted response combines both:
For the full parameter reference, see the search API reference.