4

I am currently trying to implement a sosl search query, so I can filter out non-letter characters for searching inside the salesforce database. Everything works as expected, however when I encounter a space character in the inputted data, I replace it with a wildcard for searching e.g.

FIND {"Ab" AND "cd*ef"} IN ALL FIELDS RETURNING Candidate__c(Firstname__c, Lastname__c)

I would expect to get the following candidate;

Firstname__c: Ab

Lastname__c: cd ef

However I am not receiving any result from my searchquery. With following query, the correct candidate is returned;

FIND {"Ab" AND "cd ef"} IN ALL FIELDS RETURNING Candidate__c(Firstname__c, Lastname__c)

Is this expected behaviour for the wildcards in a SOSL query and are there any workarounds? Thanks.

1 Answer 1

4

While it is not explicitly documented, but going through the documentation, it seems that you cannot expect a space character to be included in a wildcard search viz., cd*ef. From the excerpt as below from this documentation on wildcard, it seems the middle or end of your search term necessarily expects a single word with no space.

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.

Later in the same documentation, it does cover the space character.

A search for mi* meyers finds items with mike meyers or michael meyers.

So in your case if you want to search for cd ef with a wildcard, you can have the search term defined as cd* ef (with a space between * and the character e).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .