Skip to main content
The highlightPreTag parameter defines the HTML tag inserted before the matching text in highlighted attributes. It works in combination with highlightPostTag, which marks the end of the highlighted portion.

Usage

  • Set an empty string ("") to fallback to the default tag.
  • To turn off highlighting, remove the searchable attribute with the attributesToHighlight parameter.

Examples

Current API clients

Set default tag

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings { HighlightPreTag = "<em>" }
);
var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(new SearchParamsObject { Query = "query", HighlightPreTag = "<strong>" })
);

Set default tag

IndexSettings settings = new IndexSettings()
settings.HighlightPreTag = "";

index.SetSettings(settings);

Change tag for the current search

index.Search(new Query("query")
{
    HighlightPreTag = ""
});
I