LPS-42551 Fix escaping when query terms contain apostrophes