highlight

Retrieves highlights for matches in the specified text or text-array fields. Each specified field must be highlight enabled in the domain configuration. The fields and options are specified in JSON using the form {"FIELD":{"OPTION":VALUE,"OPTION:"STRING"},"FIELD":{"OPTION":VALUE,"OPTION":"STRING"}}.

You can specify the following highlight options:

  • format: specifies the format of the data in the text field: text or html. When data is returned as HTML, all non-alphanumeric characters are encoded. The default is html.

  • max_phrases: specifies the maximum number of occurrences of the search term(s) you want to highlight. By default, the first occurrence is highlighted.

  • pre_tag: specifies the string to prepend to an occurrence of a search term. The default for HTML highlights is <em>. The default for text highlights is *.

  • post_tag: specifies the string to append to an occurrence of a search term. The default for HTML highlights is </em>. The default for text highlights is *.

If no highlight options are specified for a field, the returned field text is treated as HTML and the first match is highlighted with emphasis tags: <em>search-term</em>.

For example, the following request retrieves highlights for the actors and title fields.

{ "actors": {}, "title": {"format": "text","max_phrases": 2,"pre_tag": "<b>","post_tag": "</b>"} }