Free Salesforce Developers Tutorials >

Chapter 7 - SOSL >

What is SOSL (Salesforce Object Search Language)?

What is SOSL (Salesforce Object Search Language)?

What You’ll Learn

S2 Labs

What Is SOSL In Salesforce?

SOSL is a highly optimized way of searching records in Salesforce across multiple Objects that are specified in the query. A SOSL query returns a list of list of sObjects and it can be performed on multiple objects.

When To Use SOSL In Salesforce

Whether you use SOQL or SOSL depends on whether you know which objects or fields you want to search, plus other considerations.

Use SOSL when you don’t know which object or field the data resides in, and you want to:

  • Retrieve data for a specific term that you know exists within a field. Because SOSL can tokenize multiple terms within a field and build a search index from this, SOSL searches are faster and can return more relevant results.
  • Retrieve multiple objects and fields efficiently where the objects might or might not be related to one another.
  • Retrieve data for a particular division in an organization using the divisions feature.
  • Retrieve data that’s in Chinese, Japanese, Korean, or Thai. Morphological tokenization for CJKT terms helps ensure accurate results.

Some key point:

  • In query editor, Find {Test}.
  • Find {Test} RETURNING Account(name), Contact(Name).
  • Text searches are case-insensitive.
  • Find {Test*} where asterisk(*) is a wildcard.
  • Find {Test} in Name Fields.
  • Whenever referring to ALL FIELDS, use * for emails and when specifying EMAIL fields, no need for *.
  • Find {What?} [What type?] [Where?].
  • Find {Upsert} RETURNING Account(Name,Phone), Contact(LastName), student__c(Name, Name__c).
  • Find {test OR upsert}.
  • In order to limit characters
  • Find {Test??} ? => single character.

* => zero or multiple character.

  • SOSL does not have to use a wildcard (*) as it already matches the fields based on the string match.

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

Your email address will not be published. Required fields are marked *