I am pretty much convinced about Dgraph and started my development of a social network using it. Currently, I am a bit confused about some query structure. Some help will be highly appreciated.
My User Schema is
type User @secret(field: "password") {
uuid: String! @id @search(by:[fulltext])
email: String! @search(by:[fulltext])
location: Point @search
presentAddress: Point @search
permanentAddress: Point @search
friends: [User] @hasInverse(field: friends)
contacts: [Contact]
}
type Contact {
id: ID!
name: String! @search(by:[fulltext])
number: String! @search(by:[fulltext])
email: String! @search(by:[fulltext])
phone: String! @search(by:[fulltext])
user: User @hasInverse(field: contacts)
}
I am designing a friend Recommendation query based on the current location, present address, permanent address, and contacts that I have in my database along with the friends of friends.
so I end up with the following DQL
{
var(func: eq(User.email, "email_address")) {
myscore as math(5)
User.friends {
isMyFriend as math(1)
User.friends{
fscore as math(myscore)
}
}
}
var(func: near(User.location, [90.412521,23.810331],100)) {
locationScore as math(5)
}
var(func: near(User.presentAddress, [90.412521,23.810331],100)) {
presentLS as math(5)
}
var(func: near(User.permanentAddress, [90.412521,23.810331],100)) {
permanentLS as math(5)
}
## I NEED A CONTACT MATCHING PART REMAINING
var(){
fofscore as math(fscore)
currentLocationScore as math(locationScore)
presentLocationScore as math(presentLS)
permanentLocationScore as math(permanentLS)
SCORE as math(fofscore+currentLocationScore+presentLocationScore+permanentLocationScore)
}
suggestedFriends(func: uid(SCORE), orderdesc:val(SCORE), first:10, offset: 0)
@filter(
and(
not eq(val(isMyFriend),1)
not eq(User.email,"email_address")
)
){
score : val(SCORE)
User.uuid
User.email
# expand(_all_){
# expand(_all_)
# }
}
}
Now I only need contact matching part
Any suggestion will be highly appreciated