8

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 {[email protected]} IN EMAIL FIELDS RETURNING Lead, Contact

When I escape the - dash character the SOSL query works just fine.

FIND {some\[email protected]} IN EMAIL FIELDS RETURNING Lead, Contact

Am I doing something wrong, is this a bug in Salesforce, or is the documentation incomplete?

1 Answer 1

11

Not sure why that part of the documentation is not mentioning - and + characters, but they are reserved according to this documentation:

Reserved Characters

The following characters are reserved: ? & | ! { } [ ] ( ) ^ ~ * : \ " ' + -

Reserved characters, if specified in a text search, must be escaped (preceded by the backslash \ character) in order to be properly interpreted. An error occurs if you do not precede reserved characters with a backslash. This is true even if the SearchQuery is enclosed in double quotes.

1
  • 3
    It appears your documentation is better than mine.
    – dBeltowski
    Sep 13, 2016 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .