1

I want to search in multiple fields using SOSL. I know that it allows to search in all fields using below syntax-

FIND {"Smith"} IN ALL FIELDS RETURNING contact (name), lead (name)

And also works perfectly fine with single field if I supply any field's name instead of ALL like below-

FIND {"Smith"} IN Name FIELDS RETURNING contact (name), lead (name)

What I want to try is something like below-

FIND {"Smith"} IN (NAME, COMPANY) FIELDS RETURNING contact (name), lead (name)

I have tried various things here for IN (NAME, COMPANY) like below-

  • IN NAME, COMPANY
  • IN {NAME, COMPANY}
  • IN NAME; COMPANY

Can someone please suggest if there is a way of doing it in SOSL.

3

You can't specify individual fields this way. The only options for IN X FIELDS are:

  • ALL FIELDS
  • NAME FIELDS
  • EMAIL FIELDS
  • PHONE FIELDS
  • SIDEBAR FIELDS

If you'd like, you can provide filters on the individual objects, such as:

FIND :term IN ALL FIELDS
RETURNING Lead(Name, Company WHERE Name LIKE :filter OR Company LIKE :filter)...
| improve this answer | |

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.