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.