Hi there,
Trying to build a collaborative filtering traversal where a Person is recommended Items while his disliked items from previous recommendations are excluded.
Person--ordered-->Item
Person--recommended-->Item (if person dislikes it, we update its property recommended[:dislike] = 1 else recommended[:dislike] is 0)
In two steps this works, we remove disliked items from resulting hash (the ruby way):
m = person.out_e('ordered').in_v.aggregate(:x).in('ordered').except(person).out('ordered').except(:x).group_count
person.out_e('recommended').where('dislike != :val', val:0).in_v.each { |v| m.delete(v) }
In one step (assuming that it will be faster) I can do this, but notice this is not correct because this excludes "dislikes from any person". How to make it so that it excludes "dislikes from a certain person"?
m = person.out_e('ordered').in_v.aggregate(:x).in('ordered').except(person).out('ordered').except(:x).neg_lookahead{|n| n.in_e('recommended').where('dislike != :val', val:0).in_v }.group_count
In Gremlin maybe this is doable in a single traversal via back()? Or any other traversal strategy we can apply for this case?
Cheers,
Burak