This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
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.
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
Ok thanks, got the tool...and I see what you're talking about.
So for this example,it says the terms don't match.
the search term shows as: lithium carbonate
and the trade name shows a dot character in-between the words: lithium *carbonate (it actually shows a dot, but i just used an asterisk for my visual example).
So you've helped me identify the issue! Now I'm just not sure what to do to fix it...??
I think I found the solution. I used the Data Cleansing tool, and under the section of REMOVE UNWANTED CHARACTERS I checked the box for 'tabs, linebreaks, and duplicate whitespace'. So far it looks like it's working....