1

I run 2 SOSL queries -

Query1:

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

Result: 7 records whose field value contains 'Athreya'

Query2:

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

Result: 7 records whose field value contains 'Athreya'

According to my understanding, Query1 should return records whose any field value = 'Athreya' and Query2 should return records whose any field value contains 'Athreya' (for ex. Athreyas,Athreyag,..). Is my understanding correct?

1
  • The * after the word means "Starts With" not Contains. – Eric Oct 20 '15 at 13:03
2

Your understanding is correct. QUery2 should return records whose any field contain a word that starts with Athreya and has zero, one or more trailing characters. If you want to check for only one trailing character, use ?. Query1 on the other hand only returns the records that contain the exact word Athreya

From - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_find.htm

Wildcards

You can specify the following wildcard characters to match text patterns in your search:

* - Asterisks match zero or more characters at the middle or end of your search term. For example, a search for john* finds items that start with john, such as, john, johnson, or johnny. A search for mi* meyers finds items with mike meyers or michael meyers.

? - Question marks match only one character in the middle or end of your search term. For example, a search for jo?n finds items with the term john or joan but not jon or johan. You can't use a ? in a lookup search.

0

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.