---
schema_version: "1"
id: 01e5b64909222aac6af7700825dcd4e5c6af6388252a5a3d64c9092d051965cf
title: WITH HIGHLIGHT
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-sosl-with-highlight.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-sosl-with-highlight.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a91527129df8c821c5ccd91c2a77f76c8c8eb2211050a52f0c98d136bbaa35e1
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# WITH HIGHLIGHT

`WITH HIGHLIGHT` is an optional clause that can be added to a SOSL query for business account, campaign, contact, custom object, lead, opportunity, quote, and user searches. It highlights the terms matching the search query in search results, making it easier to identify relevant content. The `WITH HIGHLIGHT` clause can be used in API version 39.0 or later. Using `WITH HIGHLIGHT` for custom fields and objects can be used in API version 40.0 and later.

Highlighted search terms are generated from the following standard and custom field types.

- Auto number
- Email
- Text
- Text Area
- Text Area (Long)

Highlighted search terms are _not_ generated from the following field types.

- Checkbox
- Compound fields
- Currency
- Date
- Date/Time
- File
- Formula
- Lookup Relationship
- Number
- Percent
- Phone
- Picklist
- Picklist (Multi-Select)
- Text Area (Rich)
- URL

## Example

The following SOSL statement returns search results with the search term `salesforce` highlighted.

```nolang
FIND {salesforce} IN ALL FIELDS RETURNING Account(Name,Description) WITH HIGHLIGHT
```

The matching terms are highlighted with `<mark>` tags. If the original search term doesn’t yield any results because of incorrect spelling, the corrected spelling of the search term is highlighted in the results.

## Example

```nolang
{
  "searchRecords" : [ {
    "attributes" : {
      "type" : "Account",
     "url" : "/services/data/v39.0/sobjects/Account/001xx000003DpxkAAC"
    },
    "Name" : "salesforce",
    "Description" : "Salesforce.com",
    "highlight.Description" : "<mark>salesforce</mark>.com",
    "highlight.Name" :
     "<mark>salesforce</mark>"
  } ]
}
```

## Example

The following statement returns search results with the search term `salesforce west` highlighted for the custom field `BuildingDescription` of the custom object `Building`.

```nolang
FIND {Salesforce West} IN ALL FIELDS RETURNING Building__c(Name, BuildingDescription__c) WITH HIGHLIGHT
```

## Usage

Search terms that contain a wildcard are not highlighted.

Other objects that are included in searches that contain `WITH HIGHLIGHT` don’t return highlighted search terms.

A maximum of 25 records per entity per SOSL query are highlighted.

## Supported APIs

The `WITH HIGHLIGHT` clause in SOSL is supported in SOAP API and REST API.
