0

Currently working on a proof of concept for a recommendation engine.

Example.

public default GraphTraversal<S, Map<Object, Long>> suggestedFriends(Long limit) {
    return out("friendship")
        .as("myFriends")
        .out("friendship")
        .as("friendsOfFriends")
        .groupCount()
        .by("email")
        .order(Scope.local)
        .by(Column.values, Order.decr);
}

I'm trying to filter the first steps matched friends before the groupCount.

What would be the correct way of doing this?

EDIT:

Got the desired output agreggating the first step results, and filtering with where on the second one..

public default GraphTraversal<S, Map<Object, Long>> suggestedFriends(Long limit) {
    return out("friendship")
        .aggregate("x")
        .as("myFriends")
        .out("friendship")
        .as("friendsOfFriends")
        .where(P.without("x"))
        .groupCount()
        .by("email")
        .order(Scope.local)
        .by(Column.values, Order.decr)
        .limit(Scope.local, limit);
}

https://github.com/erneestoc/graph_example/blob/master/src/java/com/example/ExampleTraversalDsl.java#L24

1 Answers1

1

Answered on the mailing list already, but here it is again: The query, as you have it now, looks good, but you can also remove the labels as they don't add any value:

    return out("friendship").aggregate("x")
        .out("friendship")
            .where(P.without("x"))
        .groupCount()
        .by("email")
        .order(Scope.local)
        .by(Column.values, Order.decr)
            .limit(Scope.local, limit);
Daniel Kuppitz
  • 10,846
  • 1
  • 25
  • 34