Study for the Salesforce Platform Developer Exam. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Practice this question and more.


Which data structure is returned after performing a SOSL search?

  1. A list of lists of sObjects.

  2. A map of sObject types to a list of sObjects.

  3. A map of sObject types to a list of lists of sObjects.

  4. A list of sObjects.

The correct answer is: A list of lists of sObjects.

When performing a SOSL (Salesforce Object Search Language) search, the correct data structure returned is a map of sObject types to a list of lists of sObjects. This means that the SOSL search results will categorize the returned records based on the type of sObject, and each type will contain a list of lists, where each inner list represents the sObjects that match the search criteria. In SOSL, you can search across multiple objects and fields simultaneously, and the system organizes the results to ensure that you can easily identify which records belong to which object type. For instance, if you searched for a keyword in both Contacts and Accounts, the result would give you a separate list of records for each object. Choosing a list of lists of sObjects only captures the records without the context of the object types they belong to, which is not sufficient for most use cases where clear categorization is needed. Using a simple list of sObjects would miss the necessary organization by object type, while a map of just object types to lists misses the granularity of lists under each type. Therefore, the structure that incorporates these aspects fulfills the requirements of the SOSL search effectively.