0

On salesforce i saw apps which are able to run CONTAINS queries. Even the basic list filter functionality on object list allows the CONTAINS filtering.

Using SOSL i tried the following:

List<List<SObject>> searchList = [FIND '*ben* AND *berlin*' IN ALL FIELDS 
                                  RETURNING Account(Name)];

I have an account name "BigBen" in "Berlin". I am not able to find this account using upper SOSL call. I tried different combinations, but no success. How do i do SOSL calls with CONTAINS? Using the basic list filtering i am able to use CONTAINS with "ben", it gives me the expected results.

NovumCoder
  • 4,349
  • 9
  • 43
  • 58
  • You can look this link it may be helpful https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_find.htm – Diaboloxx Nov 01 '22 at 10:36

1 Answers1

1

Unlike SOQL which supports wildcards anywhere in the search term using the LIKE comparison operator, SOSL does not allow the use wildcards at the beginning of a search term (a "starts with" search).

In this case, where you are searching only one sObject, you might do better with SOQL.

Abraham Labkovsky
  • 1,771
  • 6
  • 12