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
Lightning PracticeLightning Practice 

help on Perfect wildcard search for SOSL

HI all,

Help me out.
I need a SOSL wildcard that retrieves wildcard search exact results and near by
1.Exact Match
2.Starts with first 3 letters similar records.
3.If special characters exists in Name should retrive exact and similiar records
 I don't know my SOSl is behaving wierd,
string cus='*'+CustomerName+'*';

LIST<LIST<Sobject>> query ='FInd '+cus+' IN ALL Fields from Object__C(ID)';

Note: here CustomerName is formula field in Object__C

Please help me in good possible ways

Thanks,
Lightning Practice.
 
Naren9Naren9
Hi,
You can try with the below way:
https://developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/apexcode/apex_dynamic_sosl.htm?search_text=SOSL

Thanks,
Naren
Abdul KhatriAbdul Khatri
I am not sure what are you doing in the line 1 as you are embedding Custom Formula Field as your Search String. I don't think that is going to work.
string cus='*'+CustomerName+'*';

What you do you mean by Starts with first 3 letters similar records. Few examples will help understand.

Finally any reason of using SOSL, are you searching particual string in any string.