Search highlighting allows you to see your search term in context within search results.
In the query, you can set the following properties:
| Property | Description |
|---|---|
| snippetCount | The maximum number of distinct highlight snippets to return for each highlight
field. Note: The default number of snippets is
5.
|
| fragmentSize | The character length of each snippet. |
| prefix | The string used to mark the start of a highlight in a fragment. Note: By default, the matched term is highlighted by
surrounded by an em tag.
|
| postfix | The string used to mark the end of a highlight in a fragment. Note: By default, the matched term is highlighted by
surrounded by an em tag.
|
Following is an example query including search highlighting with the properties set:
{
"query": {
"query": "cm:content:Content Service",
"language": "afts"
},
"highlight": {
"snippetCount": 4,
"fragmentSize": 70,
"fields": [
{
"field": "cm:content"
}
]
}
}
The query returns the following output with the match surrounded by the em tag:
"snippets": [
"Alfresco <em>Content</em> Accelerator (ACA) provides a no-code, streamlined",
" on Alfresco <em>Content</em> <em>Services</em> (ACS).\nACA enables customers to view",
", search, and manage their <em>content</em> from a friendly and simple modern front",
" that the customer, or our <em>services</em> team can tweak to the customers unique needs"
]
For more information, see the Term highlighting search section in the Alfresco Content Services documentation.