To facilitate better answering of questions, if you have a question, please fill in the following info. Otherwise, please delete the template.
What I want to do
Hi, all. I want to recommend posts which are liked by my follower. and used this query
{
var(func: eq(user_name,"John")){
follow{
F as user_name
liked {
P as post
num_like as count(~liked)
}
}
}
follower_land(func:uid(P), orderdesc:val(num_like)) @filter(not) {
post
~authored {
user_name
}
~liked @filter(uid(F)) {
user_name
}
like : count(~liked @filter(uid(F)))
}
}
But I realized that I have to exclude posts, my follower wrote. (because it already seen).
What I did
{
var(func: eq(user_name,"John")){
follow{
F as uid
liked {
P as post
num_like as count(~liked)
}
}
}
follower_land(func:uid(P), orderdesc:val(num_like)) @filter(not eq(~authored,uid(F))) {
post
~authored {
user_name
}
~liked @filter(uid(F)) {
user_name
}
like : count(~liked @filter(uid(F)))
}
}
{
"name": "t",
"url": "http://localhost:8080/query?timeout=20s",
"errors": [
{
"message": ": Got error: Attribute authored is not valid scalar type while running: name:\"eq\" args:\"F\" ",
"extensions": {
"code": "ErrorInvalidRequest"
}
}
]
}
Below is one of my data sets.
{
"set": [{
"user_id":"1",
"uid" : "_:John",
"user_name":"John",
"follow":[
{
"uid":"_:dan"
}
],
"scrap":[
{
"uid":"_:land1",
"land_name": "land_1"
}
],
"authored" : [
{ "uid" : "_:p1",
"post":"This is from John. #land1",
"tagged_with" : [
{
"uid":"_:land1",
"land_name": "land_1"
}
]
}
],
"liked" : [
{
"uid" : "_:p2"
},
{
"uid" : "_:p7"
}
]
}
]
}
strong text
Dgraph metadata
dgraph version
v22.0.2