The above works within the dashboard provided that there are no special characters. Due to the nature of the value for "switch" above, it can contain a long string with various escape characters. For example a string entered could be almost any special characters (for example it could contain "regex" or "#" or "=" or "$" or "[word]" etc. etc. etc.
I have tried modifying my search query as follows (adding in |s$) after the eval for switch