SOSL WITH HIGHLIGHTING (part of Spring '17)
Thursday, January 26, 2017 at 4:16PM
sfgeneral in sosl

I'm super excited about this update being released as part of Salesforce Spring '17 (works in both SOAP/REST API 39). I've been testing it out in my sandbox. Below is a simple example of the syntax:

FIND {salesforce} IN ALL FIELDS RETURNING Lead (Company, Description) WITH HIGHLIGHT

This functionality works on the following fields types (as of right now):



You can run this simple example in the Developer console and see that it returns the results with the <mark> tag around the term.

With this functionality, it is now pretty easy to search through a lot of record data for very specific things and return back a nice highlighted list of the results without having to use or build some form of custom control.



Update on Tuesday, August 1, 2017 at 5:54PM by Registered Commentersfgeneral

One thing I have come to use since writing the original post is the "SPELL_CORRECTION" flag. 

The example from the developer documentation is pretty straightforward. When set to true, spell correction is enabled for searches that support spell correction.


Article originally appeared on Salesforce tutorials - Apex, Visualforce (
See website for complete article licensing information.