I'm trying to see if customer search terms match a product name that was later clicked on. I'm using the contains function to see if the product name contains what the customer used as a search term. For the most part it's working, but one weird thing I keep seeing is that if there is a space then the function isn't counting it as a match.
For example:
search # | search term | product name | match |
1 | nike | nike air | yes |
2 | nike air | nike air | no |
On search # 1 the product name 'nike air' contains the search term 'nike', so for my purposes that is a match.
The problem is that on search #2 even though the search term and product name are exact, it's still saying that it isn't a match. I thought maybe case was an issue, so i accounted for that (the product name is always uppercase so I made the search term uppercase). I also thought maybe leading trailing spaces were an issue, so I accounted for that (with trim). But it's still not working.
I'm guessing there's a flaw in my code?
IF [TradeName] != NULL()
AND [searchterm] != ''
AND CONTAINS(TRIM([TradeName]),Uppercase(TRIM([searchterm])))
THEN 'Yes'
ELSEIF [TradeName] != NULL()
AND [searchterm] != ''
AND NOT CONTAINS(TRIM([TradeName]),Uppercase(TRIM([searchterm])))
THEN 'No'
ELSE Null()
ENDIF