Cond in func not work as I suppose

I want to recommend users with opposite sex to the current user. I write a query as flow

{
    a as var(func: eq(user_id, "AB0000084799"), first: 1) {
        user_sex as user_sex
        fl as follow {
        }
    }
    calculate_score as var(func:eq(user_sex, cond(val(user_sex)=="M", "F", "M")))  @filter(not uid(a) and not uid(fl) and not eq(university_name, "高新大学")) @cascade {
        integral @filter(gt(score_date, "2018-04-11")){
            s as score
        }
        recent_score as sum(val(s))  
    }
    TopRecommendationCount(func: uid(calculate_score)) @filter(ge(val(recent_score), 10))  {
        total: count(uid)
    }
}

but ratel says

Expected comma or language but got: "M"

Is there something wrong?

I don’t think we support value variables with cond yet. Since value variables can usually have multiple uid => value mappings, they won’t work well with cond in every case.

Could you try something like this instead? I am getting everyone who has user_sex and removing some using NOT eq.

calculate_score as var(func: has(user_sex)) @filter(not eq(user_sex, val(user_sex)) and not uid(a) and not uid(fl) and not eq(university_name, "高新大学")) @cascade {
        integral @filter(gt(score_date, "2018-04-11")){
            s as score
        }
        recent_score as sum(val(s))  
    }

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.