SOSL Flashcards
Salesforce Object Search Language (34 cards)
What does SOSL stand for?
Salesforce Object Search Language
When is SOSL used?
SOSL can be used when the object or field where the searched data resides in is not known.
What three field types does SOSL allow searching on?
SOSL allows searching text, email, and phone fields across multiple objects simultaneously.
The ______ and _______ to be searched and fields to be returned can be specified.
objects, fields
What clause is used to specify the word or phrase to search for?
The FIND clause.
The optional _________ clause can be used to specify the information to be returned.
RETURNING
What three clauses can be used for specific text searches?
In, Where, Limit
What is the return type of a SOSL query?
Each SOSL query returns a list of lists of sObjects. A variable of type List<List<SObject>>can be used to store the results of a SOSL query in Apex.</SObject>
Example SOSL Query:
FIND {test} RETURNING Account (Id), Contact, Opportunity LIMIT 60
If we want to include fields in the search what clause would we use?
The IN Clause.
The types of text fields to search for using SOSL can be specified through the optional __________ clause.
IN SearchGroup
When using the SearchGroup phrase ________. All searchable fields are searched. It is the default setting if the IN clause is not specified.
ALL FIELDS
When using the SearchGroup phrase ________. Only email fields are searched.
EMAIL FIELDS
When using the SearchGroup phrase ________. Only name fields on standard and custom objects are searched. Some additional fields such as ‘Website’ and ‘Site’ on Account and ‘Company’ on Lead are also searched.
NAME FIELDS
When using the SearchGroup phrase ________. Only phone number fields are searched.
PHONE FIELDS
When using the SearchGroup phrase ________. Only valid records as listed in the sidebar drop-down list (Salesforce Classic only) are searched.
SIDEBAR FIELDS
Example using SearchGroup Phrasing:
FIND {Marcus} IN NAME FIELDS
The ______ clause is used to search and only return records that match a specified criteria.
WHERE
WHERE Clause Example:
FIND {test} RETURNING Account (Id WHERE Rating = ‘Hot’)
The optional _____ clause can be added to a query to specify the maximum number of rows that are returned in a search result.
LIMIT
What is the max value that can be set in a LIMIT clause?
The maximum value that can be set in a LIMIT clause is 2,000. The default limit is also 2,000
Can a LIMIT clause be applied to individual objects in a single SOSL query?
Yes
What happens when a limit is set on the entire query?
The results are evenly distributed among the objects returned.
SOSL Limit Example:
FIND {test} RETURNING Account (Id LIMIT10)
- > results = Search.query(q);
Where q is a string that represents our SOSL query.