function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
youcyouc 

SOSL help

I wrote a piece of SOSL in a VF page controller. The function is to search account with typed name and post number.

 

[FIND : customerName+'*' IN Name Fields RETURNING Account (Type, Name, Id, House_No__c where Post_Code__c =: postNr)];

 

I got only 16 records from this SOSL. Many records are missing.  I can't even find the pattern of these records. For example, I search John with postnr 1234, 16 records include John SMITH, Johnna SMITH, Kim JOHN, Kim JOHNNE.

 

If I make query with SOQL,

Select a.Name  From Account a where a.Name like :customerName+'%' And Post_Code__c =: postNr

 

It returns all the account whoes name starts with 'John' as I expected and there are196 records. But since we have almost 1 million accounts, SOQL is extremely slow compared with SOSL.

 

Can anyone help with these? Is there something I miss in the SOSL? Why it makes such big differences?

Thanks in advance.