4

I'm working on a query to find some duplicate records by name. I take the name and replace anything thats not a letter with a wildcard. I wind up with a query that looks like this:

FIND {Name*Name*} IN NAME FIELDS RETURNING ACCOUNT (Id, Name) 

I've got a few duplicate records in the sandbox:

Account(Name = 'Name4Name')
Account(Name = 'Name four Name')
Account(Name = 'Name4Name Name')

However, only "Name4Name" & "Name4Name Name" is returned as a query result.

The documentation says:

Use an asterisk (*) to find items that match zero or more characters at the middle or end of your query.

Use a question mark (?) to find items that match only one character at the middle or end of your query.

From this, I would expect all names to be returned in the query, but only the first & last ones are returned. I'm a bit stumped here - how can I get all of these records to return? Why does only one value return in the first place?


Looks like this query runs fine:

SELECT Id, Name FROM Account WHERE Name LIKE '%NAME%Name%'

Pretty weird that SOQL works fine where SOSL fails. Will post as answer later but would be interested in hearing why these two queries are different.

2
  • 1
    You mean SOSL and not SOQL, right? Commented Sep 5, 2019 at 14:24
  • Yes - thank you! Commented Sep 5, 2019 at 14:28

1 Answer 1

4

This seems like unexplainable bug. When there is exactly 1 word between 2 names like name someWord name someOtherWord, it does not return the record. However, if you add spaces for wildcard characters, it seems to be fine:

FIND {Name * Name *} IN NAME FIELDS RETURNING ACCOUNT (Name)

enter image description here

enter image description here

1
  • 1
    Thats a great catch! Surprised to see the version without spaces show up when the query has spaces. Commented Sep 5, 2019 at 17:08

You must log in to answer this question.

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