Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I use relationships in SOSL?

Example: Find all first names that start with 'Roc' within Position__c

FIND \'Roc*\' IN ALL FIELDS RETURNING Position__c(Id, Contact__r.FirstName WHERE Title__c = 'Paper Jammer')
share|improve this question

SOSL does not support traversing relationship query .

When you write a query as below

List<List<SObject>> searchList = [FIND :mySearchText IN ALL FIELDS 
                             Account (id, name,phone, BillingStreet,BillingCity,BillingState, owner.Alias,owner.MobilePhone )];

You will notice that owner.Alias will be null but you will still get ownerId and you can use ownerId to further form queries .

share|improve this answer
So is this only on standard relationships? not custom? – fourq Dec 7 '12 at 17:35
i think it will work for all – Mohith Shrivastava Dec 7 '12 at 17:47
I just checked you still get ownerId and i think you will need to run another query here .I am editing the answer . I still suspect something changed in releases as this answer is nearly three years back .Updating the answer now – Mohith Shrivastava May 17 at 16:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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