Make the search function generic to be reused by LOVAPI