According to the documentation you need to escape the following special characters in SOSL search text.
Escaping special characters
& | ! ( ) { } [ ] ^ “ ~ * ? : \ '
The -
dash character is not in that list, yet when I attempt SOSL with the -
dash character in the search text I get the following error:
line 1:14 mismatched character '-' expecting '}'
A sample SOSL that returns the error is:
FIND {some-email@gmail.com} IN EMAIL FIELDS RETURNING Lead, Contact
When I escape the -
dash character the SOSL query works just fine.
FIND {some\-email@gmail.com} IN EMAIL FIELDS RETURNING Lead, Contact
Am I doing something wrong, is this a bug in Salesforce, or is the documentation incomplete?
Best Answer
Not sure why that part of the documentation is not mentioning
-
and+
characters, but they are reserved according to this documentation: