4

Below is my SOSL query -

FIND {searchString}  
IN ALL FIELDS 
RETURNING Account(Id,Account_Number__c, RecordType.Name,Name LIMIT 16)

1) When I put searchString = '42430' in sosl query

Query 1:

 FIND {42430}  
     IN ALL FIELDS 
     RETURNING Account(Id,Account_Number__c, RecordType.Name,Name LIMIT 16)

Result: 1 record retrieved

2) When I put searchString = '42430*' in sosl query

Query 2:

 FIND {42430*}  
     IN ALL FIELDS 
     RETURNING Account(Id,Account_Number__c, RecordType.Name,Name LIMIT 16) 

Result: 6 records retrieved

According to my understanding, Query 1 should return records whose any field value contains '42430' and Query 2 should return records whose any field value Starts with '42430'.

So query 1 should return at least 6 records (query 1 results should be inclusive of query 2 results). Why query 1 is retrieving only 1 record??

On the other hand when I search 42430 in search engine, I get records whose field value is exactly equal to '42430'. How does the salesforce search engine works internally?

  • It works the same way you are putting it in SOSL. In the first query it will look for exact match not the contains so basically it is '=' operator instead of 'like' In global search also it looks for exact match. If i have to check for contains I put it as 42430 – C0DEPirate Oct 26 '15 at 7:32
  • @NickSFDC, first query doesn't look for exact match, I searched for 'rp' and was retrieving records containing 'rp1', 'testrp' as field value – Rohit Patil Oct 26 '15 at 8:24
0

When adding a term within brackets {TERM}, the query will look for the exact term within searchable fields, SOSL does not support partial matching, which would indicate that you records containing rp1 and testrp may have other searchable fields that contain rp.

For a complete reference on SOSL, please refer to the SOSL Reference Guide from the developer docs.

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.