Activity › Forums › Salesforce® Discussions › What is SOSL query ? How it works?
Tagged: Example, Salesforce Development, SOSL Query
-
What is SOSL query ? How it works?
Posted by shariq on July 14, 2017 at 1:37 PMI want to know the working of SOSL Query with Examples.
Parul replied 7 years, 8 months ago 4 Members · 3 Replies -
3 Replies
-
Hello Shariq,
SOQL statements evaluate to a list of sObjects, a single sObject, or an Integer for count method queries.
This may help you:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL.htm
- [adinserter block='9']
-
1 – SOSL stand for “Salesforce Search Language” and it is used to search the field in all the object or in particular object
2 – SOSL return List<List<sObject>>
3 – SOSL search in four field (id,name,email,phone)
4- Syntax like that –> ” Find {keyword} in ALL FIELD Returning Object_name ” (its for salesforce query editor)
5 – (for apex) –> ” List<List<sObject>> obj = [FIND ‘keyword’ IN ALL FIELD RETURNING ACCOUNT(name,email) , CONTACT(firstName,phone) ];
-
Salesforce Object Search Language (SOSL) is a simple language for searching across all multiple persisted objects simultaneously.
Sosl statements evaluate to a list of SObjects where each list contains the search results for a particular sobject type.
SOSL queries are only supported in apex classes and anonymous blocks.
We can not use a SOSL query in trigger.EX:-
The following example that searches all fields across all account and contact objects.List<List< Sobject>> searchList = [FIND ‘Text*’ IN ALL FIELDS RETURNING Account,Contact];
system.debug(‘searchlist is :’+searchList );Thanks
Log In to reply.