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
sam sjsam sj 

SOSL query doesn't work for pulling recently created/commited record

In my org, platform encryption is enabled for account object's  'Name' field.  I have a requirement/functionality to write a query to pull the records using WHERE clause (where name like '%Test%'). Due to salesforce limitations on 'WHERE' clause for encrypted fields I have to go for sosl.
   But here comes the actual issue. When I use SOSL for querying it's not fetching the record that was created a moment ago. My actual functionality works like this: User creates a record and he would verify it by searching the record recently created. But I could only get the search result only after 30 to 40 seconds later. Its taking some buffer time to get the search result. Is there any alternative I could modify the query or any other way to query.
My sosl query: 'Find :strEsc in Name Fields RETURNING Account(Name,RecordType.Name) WHERE RecordTypeId = '001q000000bxHf4')';
 
Best Answer chosen by sam sj
bob_buzzardbob_buzzard
SOSL requires that the newly created record is indexed, so there will be a period of time after it is created that it won't be retrieved in search results. I typically find its a second or two though - 30-40 sounds a very long time. Details and options to workaround (though none that really help the SOSL side of things) are at:

https://developer.salesforce.com/blogs/engineering/2014/02/salesforce-bulk-data-loads-and-full-text-search-indexes.html

All Answers

bob_buzzardbob_buzzard
SOSL requires that the newly created record is indexed, so there will be a period of time after it is created that it won't be retrieved in search results. I typically find its a second or two though - 30-40 sounds a very long time. Details and options to workaround (though none that really help the SOSL side of things) are at:

https://developer.salesforce.com/blogs/engineering/2014/02/salesforce-bulk-data-loads-and-full-text-search-indexes.html
This was selected as the best answer
sam sjsam sj
Thanks @bob for the information.