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

Set default tag

Current API clients

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings { HighlightPreTag = "<em>" }
);
IndexSettings settings = new IndexSettings()
settings.HighlightPreTag = "";

index.SetSettings(settings);

Current API clients

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