Slight refactor of ls query to avoid duplicate results when using synonymy matching.