SOSL full-text search across objects: sosl runs a raw SOSL string, find builds one safely from a search term.
Values
SOSL_RESERVED
SOSL_RESERVED: Vec [
"\\",
"?",
"&",
"|",
"!",
"{",
"}",
"[",
"]",
"(",
")",
"^",
"~",
"*",
":",
"\"",
"'",
"+",
"-"
]
Functions
build-sosl
fn (term: Str, options: Map): Str
Build a SOSL statement from a plain search term. options: in
("ALL" (default), "NAME", "EMAIL", "PHONE", or "SIDEBAR";
"FIELDS" is appended), returning (Vec of object clauses such as
"Contact(Id, Name, Email)" or "Lead"), limit. Exposed for
testing; find uses it.
escape-sosl
fn (term: Str): Str
Escape SOSL reserved characters (? & | ! { } [ ] ( ) ^ ~ * : \\ " ' + -) with a backslash so a user-supplied term searches literally inside FIND {...}. Exposed for testing.
find
fn (term: Str): Vec
fn (term: Str, options: Map): Vec
fn (term: Str, options: Map, opts: Map): Vec
Search for a plain term (escaped for you) and return the matching
records. See build-sosl for the options.
Example
people ::salesforce::search/find("ada@example.com", {
in: "EMAIL",
returning: ["Contact(Id, Name, Email)", "Lead(Id, Name, Email)"],
limit: 10
})
sosl
fn (statement: Str): Map
fn (statement: Str, opts: Map): Map
GET /search?q= - Run a raw SOSL statement. Returns
{searchRecords}: matching records across objects, each with
attributes.type.
Example
hits ::salesforce::search/sosl("FIND {Lovelace} IN NAME FIELDS RETURNING Contact(Id, Name), Lead(Id, Name)")
hits.searchRecords