Add search function with query and category field