At the highest level, a SOSL query specifies search terms and scope. The search terms are a list of string literals and can include wildcards. The search scope is fields containing string data from one or more objects. This excludes Number, Date, and Checkbox fields from being searched with SOSL.
SOSL query syntax consists of four parts:
Query—The query is one or more words or phrases to search on. The query can include the wildcards *
(matches any number of characters) and ?
(matches any single character) at the middle or end of search terms. Enclose a search term in quotation marks to perform an exact match on multiple words. Use the logical operators AND
, OR
, and AND NOT
to combine search terms and parentheses to control the order in which they’re evaluated. Note that searches are not case sensitive.
Search group—The search group is an optional part of the SOSL query indicating the types of fields to search in each object. Valid values are ALL FIELDS
(all string fields), NAME FIELDS
(the standard Name field only), EMAIL FIELDS
(all fields of type Email), and PHONE FIELDS
(all fields of type Phone). The default value is ALL FIELDS
.
Field specification—The field specification is a comma-separated list of objects to include in the result. By default, the Id
field of each object is included. Optionally, you can specify additional fields to return by enclosing them in parentheses. You can also specify conditional filters using the same syntax as the SOQL WHERE
clause, set the sort order with the ORDER BY
keyword, and use the LIMIT
keyword to limit the number of records returned per object.
Record limit—This optional value specifies the maximum number of records returned by the entire query, from all the objects queried. If a record limit is not provided, it defaults to the maximum of 200.
These four parts are combined in the following syntax: FIND
'query' IN
search group RETURNING
field specification LIMIT
record limit. The single quotation marks around query
are required.
18.216.96.94