You need to sign in to do that
Don't have an account?
Suma G 7
Want to search in specific fields not ALL FIELDS in SOSL
Hi All,
i have a SOSL in my Apex code which like below:
But, my requirement is lik, i should not search in ALL FIELDS, but i have some specific fields like Title and Tagcsv .. any suggestions to achieve this.
Thanks in advance.
Regards,
Suma.
i have a SOSL in my Apex code which like below:
String searchQuery = 'FIND \'' + String.escapeSingleQuotes(searchInput) + '\' IN ALL FIELDS RETURNING contentVersion (Title, Tagscsv, Id, Availability__c, Colour_Enabled__c' + queryWhere + ' ORDER BY Title LIMIT 500) ';
But, my requirement is lik, i should not search in ALL FIELDS, but i have some specific fields like Title and Tagcsv .. any suggestions to achieve this.
Thanks in advance.
Regards,
Suma.
SOSL is used only when you don't know which Field/Object to search for the keyword.
When you know the Object to be queried, fields to be returned, fields to be searched upon, then you shoud used SOQL.
Sample:
(Please change field api names and Object api names to match with correct api names in your org)
If you think that SOQL won't address your problem then you can write SOSL query. But SOSL can only search on a common group of fields like Name, Email, Phone. You can't write SOSL to search only on selected fields of your choice.
More info here:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_in.htm
If this helps solve your problem
Please mark this as Best Answer.
All Answers
SOSL is used only when you don't know which Field/Object to search for the keyword.
When you know the Object to be queried, fields to be returned, fields to be searched upon, then you shoud used SOQL.
Sample:
(Please change field api names and Object api names to match with correct api names in your org)
If you think that SOQL won't address your problem then you can write SOSL query. But SOSL can only search on a common group of fields like Name, Email, Phone. You can't write SOSL to search only on selected fields of your choice.
More info here:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_in.htm
If this helps solve your problem
Please mark this as Best Answer.