Skip to main content
  • Type: list<string>
  • Default: null(all searchable attributes)
  • Scope: settings,search

Usage

  • By default, all searchable attributes are highlighted.
  • The special value * may be used to highlight all attributes.
  • Pass an empty array ([]) to turn off highlighting.
  • Algolia highlights the first 50,000 characters of the whole result set (5,000 logograms for CJK languages). This limit prevents impacting the user experience by ensuring a fast response time even with large results.
  • When highlighting is enabled, each hit in the response contains a _highlightResult object.
  • When enabled, each hit includes a _highlightResult object with metadata about the matches.

_highlightResult

Examples

Current API clients

Set default list of attributes to highlight

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings
  {
    AttributesToHighlight = new List<string> { "author", "title", "content" },
  }
);

Make all attributes highlighted by default

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings { AttributesToHighlight = new List<string> { "*" } }
);
var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject
    {
      Query = "query",
      AttributesToHighlight = new List<string> { "title", "content" },
    }
  )
);

Set default list of attributes to highlight

IndexSettings settings = new IndexSettings()
settings.AttributesToHighlight = new List
{
    "author",
    "title",
    "content"
};

index.SetSettings(settings);

Make all attributes highlighted by default

IndexSettings settings = new IndexSettings()
settings.AttributesToHighlight = new List
{
    "*"
};


index.SetSettings(settings);

Override list of attributes to highlight for the current search

index.Search(new Query("query")
{
    AttributesToHighlight = new List { "title", "content" }
});
I