WITH SPELL_CORRECTION and WITH HIGHLIGHT – SOSL clauses in Summer’17

WITH SPELL_CORRECTION and WITH HIGHLIGHT clauses in Summer’17 for SOSL (Salesforce Object Search Language): Below are the two more SOSL clauses available in salesforce with Summer’17 release (API version 40).

1. WITH HIGHLIGHT

2. WITH SPELL_CORRECTION

WITH HIGHLIGHT:

This is an optional clause that can be added to a SOSL query for business account, campaign, contact, lead, opportunity, quote, user and custom object searches. It highlights the terms matching the search query in search results, making it easier to identity relevant content.

This clause was available for business account, campaign, contact, lead, opportunity, quote, user object with version 39 or later. It is also available for Custom object and fields with version 40 or later.

Highlighted search terms are generated only from the following standard and custom field types:

Auto number, Email, Text, Text Area and Text Area (Long).

Example:

FIND {stutorials} IN ALL FIELDS RETURNING Account(Name,Description) WITH HIGHLIGHT

Above SOSL statement returns search results with search item stutorials highlighted.

Important notes about WITH HIGHLIGHT clause:

– Only 25 records per entity per SOSL query are highlighted.

– Search teams that contains a wildcard are not highlighted.

– Other objects that are included in searches that contain WITH HIGHLIGHT don’t return highlighted search terms.

– This clause in SOSL is supported in SOAP API and REST API.

WITH SPELL_CORRECTION:

– This is an optional clause that can be added to a SOSL query.

– When it set to true, spell correction is enabled for searches that support spell correction. When it set to false, spell correction is not enabled. Default value is true.

– This clause is available with version 40 or later versions.

Example:

FIND {your search string} IN ALL FIELDS RETURNING Account WITH SPELL_CORRECTION = false

– This clause in SOSL is supported in SOAP API, REST API and Apex.