Fix the search query escaping

fixes #2619