We keeping facing the “Search pages return 0 results if there is an unknown query parameter” problem every time a new external site links to our site, most recently for Pinterest ads that add epik and pp query parameters.
Is there a known/common generic fix for this?
In the accelerator in SearchQueryMapper.SearchQueryResolver, after the blacklisted query parameters, there is some code to handle other parameters. Not sure whether this code assumes anything not blacklisted is a valid query filter. But I guess this is where a “generic” fix should go.
Since the logic is in the Accelerator, you could implement your own validation of the query parameter. Maybe that for the default switch case, it will try and fetch a product field definition by that id and break if it doesn’t exist.
There is a list of parameters in the accelerator that are excluded from being included as filters in the search and the simples solution is to extend that list with known parameters but a perhapps better solution is to do like Nils suggest and look if the parameter is actually a field in litium.
Look in the searchquerymapper
foreach (var key in queryString.AllKeys)
{
switch (key)
{
// Google Analytics www.demo.se/?utm_source=source&utm_medium=medium&utm_term=term&utm_content=content&utm_campaign=campaignname
case "utm_source":
case "utm_medium":
case "utm_term":
case "utm_content":
case "utm_campaign":
// Google AdWords
case "gclid":
// Common query parameters that now should go into filters
case "_":
case "UseWorkCopy":
case "callback":
case "featureClass":
case "style":
case null:
Thank you. Yeah, that code is what I was referring to as “blacklisted query parameters” in the original question. That code is what we don’t want to keep adding to.