0

Trying to search multiple terms in SOSL in APEX. I tried this singular, of course works:

[FIND 'searchOne' IN ALL FIELDS RETURNING ACCOUNT]

But these don't work:

  • [FIND 'searchOne' OR 'searchTwo' ....
  • [FIND {'searchOne','searchTwo'} ....
  • [FIND (searchOne', 'searchTwo') ....

Error is:

'(' not expected (or something..etc)

My goal is bulkification and searching a value in an Encrypted Field. I want to be able to get all matching records based on a set of terms.

0

In Apex, it's just a normal string:

[FIND 'searchOne or searchTwo' in all fields ...

This syntax is slightly different than the API, which is probably where the confusion is coming from. You can also use quotation marks (") to group terms, etc, just like you can in normal SOSL.

[FIND '"searchOne" or "searchTwo"' in all fields ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.