Use Supabase SDK to query referenced table using OR operator

I have two tables students and classes. These two have a relationship student_id. I want to get classes data using search values which will query students db. Here is what I tried

 supabase.from("classes")
        .select(`*, students:student_id(*)`)
        .or(`first_name.ilike.%${search_value}%,last_name.ilike.%${search_value}%`)  
        .eq("user_id",user?.id)

I’m getting the following error

{
    "code": "PGRST100",
    "details": "unexpected "f" expecting "not" or operator (eq, gt, ...)",
    "hint": null,
    "message": ""failed to parse logic tree ((students..first_name.ilike.%komichi%,students.last_name.ilike.%komichi%))" (line 1, column 13)"
}

I tried querying in reverse instead of from “classes” I do from “students” and it works, I just want to understand if the solution I tried initially can be fixed, is there a different character which I can use instead of . to show I’m querying a referenced table.